// Make from two timestamps public static HDateTimeRange make(HDateTime start, HDateTime end) { if (!start.TimeZone.hequals(end.TimeZone)) { throw new ArgumentException("start.TimeZone != end.TimeZone"); } return(new HDateTimeRange(start, end)); }
// Construct from timestamp, value public static HHisItem make(HDateTime ts, HVal val) { if (ts == null || val == null) { throw new ArgumentException("ts or val is null"); } return(new HHisItem(ts, val)); }
public int CompareTo(HDateTime that) { // Original Java compared millis which is the milliseconds sicne epoch at UTC // equivalent for C# = compare the datetime offset for UTC DateTimeOffset dtoCopy = that.CopyOfDTO; return(m_dtoParsed.ToUniversalTime().CompareTo(dtoCopy.ToUniversalTime())); }
// Constructor with ticks and DN TimeZone instance public static HDateTime make(long ticks, HTimeZone tz) { // use DateTimeOffset to decode ticks to fields DateTimeOffset dt = new DateTimeOffset(ticks, tz.dntz.BaseUtcOffset); HDateTime ts = new HDateTime(dt, tz); return(ts); }
public override bool hequals(object obj) { if (!(obj is HDateTime)) { return(false); } HDateTime x = (HDateTime)obj; return(date.hequals(x.date) && time.hequals(x.time) && Offset == x.Offset && TimeZone.hequals(x.TimeZone)); }
/** * Parse from string using the given timezone as context for * date based ranges. The formats are: * - "today" * - "yesterday" * - "{date}" * - "{date},{date}" * - "{dateTime},{dateTime}" * - "{dateTime}" // anything after given timestamp * Throw ParseException is invalid string format. */ public static HDateTimeRange make(string str, HTimeZone tz) { // handle keywords str = str.Trim(); if (str.CompareTo("today") == 0) { return(make(HDate.today(), tz)); } if (str.CompareTo("yesterday") == 0) { return(make(HDate.today().minusDays(1), tz)); } // parse scalars int comma = str.IndexOf(','); HVal start = null, end = null; if (comma < 0) { start = new HZincReader(str).readVal(); } else { start = new HZincReader(str.Substring(0, comma)).readVal(); end = new HZincReader(str.Substring(comma + 1)).readVal(); } // figure out what we parsed for start,end if (start is HDate) { if (end == null) { return(make((HDate)start, tz)); } if (end is HDate) { return(make((HDate)start, (HDate)end, tz)); } } else if (start is HDateTime) { if (end == null) { return(make((HDateTime)start, HDateTime.now(tz))); } if (end is HDateTime) { return(make((HDateTime)start, (HDateTime)end)); } } throw new FormatException("Invalid HDateTimeRange: " + str); }
} // size is two - timestamp and value // Private constructor private HHisItem(HDateTime ts, HVal val) : base(new Dictionary <string, HVal>(11)) { TimeStamp = ts; hsVal = val; }
public static HaystackDateTime Map(HDateTime value) { return(value.Source); }
// Private constructor private HDateTimeRange(HDateTime start, HDateTime end) { Start = start; End = end; }
// Get HDate for current time in default timezone public static HDate today() { return(HDateTime.now().date); }
// Convert this date into HDateTime for midnight in given timezone. public HDateTime midnight(HTimeZone tz) { return(HDateTime.make(this, HTime.MIDNIGHT, tz)); }
public static HDateTimeRange make(HDateTime start, HDateTime end) => M.Map(new HaystackDateTimeRange(M.Map(start), M.Map(end)));
public static HHisItem make(HDateTime ts, HVal val) => M.Map(new HaystackHistoryItem(M.Map(ts), M.Map(val)));