private HDateTime(DateTimeOffset dto, HTimeZone htz) { m_dtoParsed = dto; TimeZone = htz; date = HDate.make(dto.Year, dto.Month, dto.Day); time = HTime.make(dto.Hour, dto.Minute, dto.Second, dto.Millisecond); }
/** Make a range which encompasses the previous year. */ public static HDateTimeRange lastYear(HTimeZone tz) { HDate today = HDate.today(); HDate first = HDate.make(today.Year - 1, 1, 1); HDate last = HDate.make(today.Year - 1, 12, 31); return(make(first, last, tz)); }
/** Make a range which encompasses the current month. */ public static HDateTimeRange thisMonth(HTimeZone tz) { HDate today = HDate.today(); HDate first = HDate.make(today.Year, today.Month, 1); HDate last = HDate.make(today.Year, today.Month, DateTime.DaysInMonth(today.Year, today.Month)); return(make(first, last, tz)); }
/** Make a range which encompasses the previous month. */ public static HDateTimeRange lastMonth(HTimeZone tz) { HDate today = HDate.today(); DateTime dttoday = new DateTime(today.Year, today.Month, today.Day); DateTime dtLastMonth = dttoday.AddMonths(-1); HDate lastMonth = HDate.make(dtLastMonth.Year, dtLastMonth.Month, dtLastMonth.Day); HDate first = HDate.make(lastMonth.Year, lastMonth.Month, 1); HDate last = HDate.make(lastMonth.Year, lastMonth.Month, DateTime.DaysInMonth(lastMonth.Year, lastMonth.Month)); return(make(first, last, tz)); }
// Parse from string fomat "YYYY-MM-DD" or raise FormatException (ParseException) public static HDate make(string s) { DateTime dtParsed = DateTime.Now; if (!DateTime.TryParseExact(s, "yyyy'-'MM'-'dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out dtParsed)) { throw new FormatException("Invalid date string: " + s); } return(HDate.make(dtParsed.Year, dtParsed.Month, dtParsed.Day)); }
// Constructor with date and time (to sec) fields public static HDateTime make(int year, int month, int day, int hour, int min, int sec, HTimeZone tz) { return(make(HDate.make(year, month, day), HTime.make(hour, min, sec), tz)); }