Exemplo n.º 1
0
 // 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));
 }
Exemplo n.º 2
0
 // 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));
 }
Exemplo n.º 3
0
        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()));
        }
Exemplo n.º 4
0
        // 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);
        }
Exemplo n.º 5
0
        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));
        }
Exemplo n.º 6
0
        /**
         * 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);
        }
Exemplo n.º 7
0
        }                                // size is two - timestamp and value

        // Private constructor
        private HHisItem(HDateTime ts, HVal val) : base(new Dictionary <string, HVal>(11))
        {
            TimeStamp = ts;
            hsVal     = val;
        }
Exemplo n.º 8
0
 public static HaystackDateTime Map(HDateTime value)
 {
     return(value.Source);
 }
Exemplo n.º 9
0
 // Private constructor
 private HDateTimeRange(HDateTime start, HDateTime end)
 {
     Start = start;
     End   = end;
 }
Exemplo n.º 10
0
 // Get HDate for current time in default timezone
 public static HDate today()
 {
     return(HDateTime.now().date);
 }
Exemplo n.º 11
0
 // Convert this date into HDateTime for midnight in given timezone.
 public HDateTime midnight(HTimeZone tz)
 {
     return(HDateTime.make(this, HTime.MIDNIGHT, tz));
 }
Exemplo n.º 12
0
 public static HDateTimeRange make(HDateTime start, HDateTime end)
 => M.Map(new HaystackDateTimeRange(M.Map(start), M.Map(end)));
Exemplo n.º 13
0
 public static HHisItem make(HDateTime ts, HVal val) => M.Map(new HaystackHistoryItem(M.Map(ts), M.Map(val)));