Package railo.runtime.functions.dateTime

Source Code of railo.runtime.functions.dateTime.DaysInYear

/**
* Implements the CFML Function daysinyear
*/
package railo.runtime.functions.dateTime;

import java.util.TimeZone;

import railo.commons.date.DateTimeUtil;
import railo.commons.date.TimeZoneUtil;
import railo.runtime.PageContext;
import railo.runtime.exp.ExpressionException;
import railo.runtime.exp.PageException;
import railo.runtime.functions.BIF;
import railo.runtime.op.Caster;
import railo.runtime.type.dt.DateTime;

public final class DaysInYear extends BIF {

  private static final long serialVersionUID = -2900647153777735688L;

  public static double call(PageContext pc , DateTime date) {
    return _call(pc, date, pc.getTimeZone());
  }
 
  public static double call(PageContext pc , DateTime date, String strTimezone) throws ExpressionException {
    return _call(pc, date, strTimezone==null?pc.getTimeZone():TimeZoneUtil.toTimeZone(strTimezone));
  }
 
  private static double _call(PageContext pc , DateTime date,TimeZone tz) {
    DateTimeUtil util = DateTimeUtil.getInstance();
    return util.isLeapYear(util.getYear(tz, date))?366:365;
  }
 
  @Override
  public Object invoke(PageContext pc, Object[] args) throws PageException {
    if(args.length==1)return call(pc,Caster.toDatetime(args[0],pc.getTimeZone()));
    return call(pc,Caster.toDatetime(args[0],pc.getTimeZone()),Caster.toString(args[1]));
  }
}
TOP

Related Classes of railo.runtime.functions.dateTime.DaysInYear

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.