001    /**
002     * Implements the Cold Fusion Function dayofweek
003     */
004    package railo.runtime.functions.dateTime;
005    
006    import java.util.Locale;
007    import java.util.TimeZone;
008    
009    import railo.commons.date.DateTimeUtil;
010    import railo.commons.date.TimeZoneUtil;
011    import railo.runtime.PageContext;
012    import railo.runtime.exp.ExpressionException;
013    import railo.runtime.ext.function.Function;
014    import railo.runtime.type.dt.DateTime;
015    
016    public final class DayOfWeek implements Function {
017            
018            public static double call(PageContext pc , DateTime date) {
019                    return _call(pc, date, pc.getTimeZone());
020            }
021            
022            public static double call(PageContext pc , DateTime date, String strTimezone) throws ExpressionException {
023                    return _call(pc, date, strTimezone==null?pc.getTimeZone():TimeZoneUtil.toTimeZone(strTimezone));
024            }
025    
026            private static double _call(PageContext pc , DateTime date,TimeZone tz) {
027                    return DateTimeUtil.getInstance().getDayOfWeek(Locale.US,tz, date);
028            }
029    }