/// <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); } }
/// <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; }
// 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)); }
// 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))); }
/// <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); }
public ZDateTimeRange(string start, string end, ZTimeZone zone) { _start = new ZDateTime(start, zone); _end = new ZDateTime(end, zone); }
public ZDateTimeRange(ZDateTime start, ZDateTime end) { _start = start; _end = end; }
// 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)); }
/// <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()); }
/// <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()); }
public override bool Equals(object obj) { ZDateTime o = (ZDateTime)obj; return(_utc == o._utc && _zone == o._zone); }