001    package railo.runtime.functions.international;
002    
003    import java.util.Locale;
004    import java.util.TimeZone;
005    
006    import railo.commons.date.DateTimeUtil;
007    import railo.commons.date.TimeZoneUtil;
008    import railo.runtime.PageContext;
009    import railo.runtime.exp.ExpressionException;
010    import railo.runtime.ext.function.Function;
011    import railo.runtime.i18n.LocaleFactory;
012    import railo.runtime.type.dt.DateTime;
013    
014    public final class LSWeek implements Function {
015            
016            public static double call(PageContext pc , DateTime date) {
017                    return _call(pc, date, pc.getLocale(), pc.getTimeZone());
018            }
019            
020            public static double call(PageContext pc , DateTime date, String strLocale) throws ExpressionException {
021                    return _call(pc, date, LocaleFactory.getLocale(strLocale),pc.getTimeZone());
022            }
023            
024            public static double call(PageContext pc , DateTime date, String strLocale, String strTimezone) throws ExpressionException {
025                    return _call(pc, date, 
026                                    strLocale==null?pc.getLocale():LocaleFactory.getLocale(strLocale),
027                                    strTimezone==null?pc.getTimeZone():TimeZoneUtil.toTimeZone(strTimezone));
028            }
029            
030            private static double _call(PageContext pc , DateTime date,Locale locale,TimeZone tz) {
031                    return DateTimeUtil.getInstance().getWeekOfYear(locale,tz, date);
032            } 
033    }