001    package railo.runtime.functions.string;
002    
003    import java.util.TimeZone;
004    
005    import railo.commons.date.TimeZoneUtil;
006    import railo.runtime.PageContext;
007    import railo.runtime.exp.PageException;
008    import railo.runtime.ext.function.Function;
009    import railo.runtime.op.date.DateCaster;
010    
011    /**
012     * Implements the CFML Function parsedatetime
013     */
014    public final class ParseDateTime implements Function {
015    
016            private static final long serialVersionUID = -2623323893206022437L;
017            
018            public static railo.runtime.type.dt.DateTime call(PageContext pc , Object oDate) throws PageException {
019                    return _call(oDate,pc.getTimeZone());
020            }
021            public static railo.runtime.type.dt.DateTime call(PageContext pc , Object oDate, String popConversion) throws PageException {
022                    return _call(oDate,pc.getTimeZone());
023            }
024            public static railo.runtime.type.dt.DateTime call(PageContext pc , Object oDate, String popConversion,String strTimezone) throws PageException {
025                    return _call(oDate,strTimezone==null?pc.getTimeZone():TimeZoneUtil.toTimeZone(strTimezone));
026            }
027            private static railo.runtime.type.dt.DateTime _call( Object oDate,TimeZone tz) throws PageException {
028                    // MUSt implement popConversion
029                    return DateCaster.toDateAdvanced(oDate,tz);
030            }
031    }