internal DateTimeStr(string pattern, Locale locale, Date d) { this.pattern = pattern; this.m_locale = locale; this.year = d.getYear(); this.mon = d.month(); this.day = d.getDay(); try { this.weekday = d.weekday(); } catch (Exception) {} }
////////////////////////////////////////////////////////////////////////// // Constructors ////////////////////////////////////////////////////////////////////////// internal DateTimeStr(string pattern, Locale locale, DateTime dt) { this.pattern = pattern; this.m_locale = locale; this.year = dt.getYear(); this.mon = dt.month(); this.day = dt.getDay(); this.hour = dt.getHour(); this.min = dt.getMin(); this.sec = dt.getSec(); this.ns = dt.getNanoSec(); this.weekday = dt.weekday(); this.tz = dt.tz(); this.dst = dt.dst(); }
internal static int weekOfYear(int year, int month, int day, Weekday startOfWeek) { int firstWeekday = DateTime.firstWeekday(year, 0); // zero based int lastDayInFirstWeek = 7 - (firstWeekday - startOfWeek.ord); // special case for first week if (month == 0 && day <= lastDayInFirstWeek) return 1; // compute from dayOfYear - lastDayInFirstWeek int doy = dayOfYear(year, month, day) + 1; int woy = (doy - lastDayInFirstWeek - 1) / 7; return woy + 2; // add first week and make one based }
public long weekOfYear(Weekday startOfWeek) { return weekOfYear(getYear(), month().ord, getDay(), startOfWeek); }
public static long weekdayInMonth(long year, Month mon, Weekday weekday, long pos) { return weekdayInMonth((int)year, mon.ord, weekday.ord, (int)pos); }
public long weekOfYear(Weekday startOfWeek) { return(DateTime.weekOfYear(getYear(), month().ord, getDay(), startOfWeek)); }
public long weekOfYear() { return(weekOfYear(Weekday.localeStartOfWeek())); }
public static long weekdayInMonth(long year, Month mon, Weekday weekday, long pos) { return(weekdayInMonth((int)year, mon.ord, weekday.ord, (int)pos)); }