Exemplo n.º 1
0
 /// <summary>
 /// Max of 2 times
 /// </summary>
 /// <param name="a">The 1st time.</param>
 /// <param name="b">The 2nd time.</param>
 public static ZDateTime Max(ZDateTime a, ZDateTime b)
 {
     if (a.Clock > b.Clock)
     {
         return(a);
     }
     else
     {
         return(b);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Create date from string & zone spec
        /// </summary>
        /// <param name='date'>
        /// Date as string in some default known format
        /// </param>
        /// <param name='zone'>
        /// Zone.
        /// </param>
        public ZDateTime(string date, ZTimeZone zone = null)
        {
            if (zone == null)
            {
                zone = DefaultZoneFor(date);
            }

            ZDateTime parsed = Parse(date, zone);

            _utc   = parsed.Clock;
            _zone  = parsed.TimeZone;
            _parts = parsed._parts;
        }
Exemplo n.º 3
0
        // Operations


        /// <summary>
        /// Convert to date/time (within current day, may be before current time)
        /// </summary>
        /// <returns>
        /// The date/time set according to this time spec.
        /// </returns>
        /// <param name='zone'>
        /// Zone.
        /// </param>
        public ZDateTime ToTime(long Tnow = 0L, ZTimeZone zone = null)
        {
            if (zone == null)
            {
                zone = ZTimeZone.Local;
            }

            if (Tnow == 0L)
            {
                Tnow = Clock.Now;
            }

            ZDateTime now = new ZDateTime(Tnow, zone);

            return(new ZDateTime(now.Year, now.Month, now.Day, Hour, Minute, Second, MilliSecond, zone));
        }
Exemplo n.º 4
0
        // Operations


        /// <summary>
        /// Determine if time for given date within time-interval
        /// </summary>
        /// <param name='date'>
        /// date from which time is extracted (in local timezone)
        /// </param>
        public bool Within(ZDateTime date)
        {
            return(Within(ZTime.TimeOf(date)));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Determine whether given time within the specified time range.
        /// </summary>
        public bool Within(ZDateTime time)
        {
            long clock = time.Clock;

            return(clock >= _start.Clock && clock <= _end.Clock);
        }
Exemplo n.º 6
0
 public ZDateTimeRange(string start, string end, ZTimeZone zone)
 {
     _start = new ZDateTime(start, zone);
     _end   = new ZDateTime(end, zone);
 }
Exemplo n.º 7
0
 public ZDateTimeRange(ZDateTime start, ZDateTime end)
 {
     _start = start;
     _end   = end;
 }
Exemplo n.º 8
0
        // Class Methods



        /// <summary>
        /// Get Time component of given date
        /// </summary>
        /// <param name='date'>
        /// date (date/time)
        /// </param>
        public static ZTime TimeOf(ZDateTime date)
        {
            return(new ZTime(date.Hour, date.Minute, date.Second, date.Millisecond));
        }
Exemplo n.º 9
0
        /// <summary>
        /// provide date as excel gmt form (2007-01-04 23:11:02.340).
        /// </summary>
        public string ToExcelDateTime(ZTimeZone zone)
        {
            var ztime = new ZDateTime(Clock, zone);

            return(ztime.ToExcelDateTime());
        }
Exemplo n.º 10
0
        /// <summary>
        /// provide date as excel gmt form (2007-01-04 23:11:02.340)..
        /// </summary>
        public static string ToExcelDateTime(long time)
        {
            var ztime = new ZDateTime(time, ZTimeZone.UTC);

            return(ztime.ToExcelDateTime());
        }
Exemplo n.º 11
0
        public override bool Equals(object obj)
        {
            ZDateTime o = (ZDateTime)obj;

            return(_utc == o._utc && _zone == o._zone);
        }