Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
        /** 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));
        }
Ejemplo n.º 3
0
        /** 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));
        }
Ejemplo n.º 4
0
        /** 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));
        }
Ejemplo n.º 5
0
        // 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));
        }
Ejemplo n.º 6
0
 // 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));
 }