Example #1
0
 public static JwTimestamp CreateNowUtc(int utcOffset)
 {
     JwTimestamp ts = new JwTimestamp();
     ts.SetNowUtc();
     ts.SubtractHours(utcOffset);
     return ts;
 }
Example #2
0
 /**
  * Format the timestamp using the formats defined in
  * JwDateUtility.format() and JwTimeUtility.format().
  */
 public static String Format(JwTimestamp ts, String format)
 {
     String s = format;
     s = JwDateUtility.Format(ts.GetDate(), s);
     s = JwTimeUtility.Format(ts.GetTime(), s);
     return s;
 }
Example #3
0
 public String Format(JwTimestamp ts)
 {
     return JwUtility.Format(
         getFormat(),
         _datePolicy.format(ts.GetDate()),
         _timePolicy.format(ts.GetTime()));
 }
Example #4
0
 //# __________ PROTOCOL :: INSTANCE CREATION __________ #//
 public static JwTimestampInterval Create(JwTimestamp start, JwTimestamp end)
 {
     JwTimestampInterval ti;
     ti = new JwTimestampInterval();
     ti.SetStart(start);
     ti.SetEnd(end);
     return ti;
 }
Example #5
0
 //# __________ PROTOCOL :: INSTANCE CREATION __________ #//
 public static JwTimestamp CreateTimestamp(JwDate d, JwTime t)
 {
     JwTimestamp ts;
     ts = new JwTimestamp();
     ts.SetDate(d);
     ts.SetTime(t);
     return ts;
 }
Example #6
0
 public JwTimestamp InferActualDepartureFromActualArrival(JwTimestamp actualArrival)
 {
     JwTimestamp ts = actualArrival.GetTimestampCopy();
     ts.AddDuration(GetTimezoneOffset());
     ts.SubtractDuration(GetTransitDuration());
     return ts;
 }
Example #7
0
        public VmTruck CreateTruckForScheduledArrival(JwTimestamp expectedArrivalLocalTs)
        {
            JwTimestamp expectedDepartureLocalTs = ComputeScheduledDepartureLocalTimestampFromScheduledArrival(expectedArrivalLocalTs);

            VmTruck truck = new VmTruck();
            truck.ExpectedDepartureLocalTs = expectedDepartureLocalTs;
            truck.CarrierCode = CarrierCode;
            truck.Number = FlightNumber;
            truck.OriginAirportCode = OriginAirportCode;
            truck.DestinationAirportCode = DestinationAirportCode;

            return truck;
        }
Example #8
0
 public JwTimestamp ComputeScheduledDepartureLocalTimestampFromScheduledArrival(JwTimestamp scheduledArrivalTs)
 {
     JwTimestamp ts = scheduledArrivalTs.GetTimestampCopy();
     ts.SubtractDuration( GetTransitDuration());
     ts.SubtractDuration( GetTimezoneOffset());
     return ts;
 }
Example #9
0
 public static String Format_m_dd_yy_h_mm_ss_am(JwTimestamp ts)
 {
     return JwDateUtility.Format_m_dd_yy(ts.GetDate()) +
         " " +
         JwTimeUtility.Format_h_mm_ss_am(ts.GetTime());
 }
Example #10
0
 public bool IsOnOrAfter(JwTimestamp d)
 {
     return CompareTo(d) >= 0;
 }
Example #11
0
 //# __________ PROTOCOL :: CONTRUCTOR __________ #//
 public JwTimestampInterval()
 {
     _start = null;
     _end = null;
 }
Example #12
0
 public void SetEnd(JwTimestamp ts)
 {
     _end = ts;
 }
Example #13
0
 public bool IsAfter(JwTimestamp d)
 {
     return CompareTo(d) > 0;
 }
Example #14
0
        //# __________ PROTOCOL :: TESTING __________ #//
        public bool HasArrivedEarly(JwTimestamp scheduledArrivalTs)
        {
            if(ActualArrivalLocalTs == null) return false;

            return ActualArrivalLocalTs.IsBefore(scheduledArrivalTs);
        }
Example #15
0
 public static JwTimestamp CreateTimestamp(DateTime x)
 {
     // kludge (err) - need to learn how to check DateTime for empty
     //if ( dt == null ) return null;
     JwTimestamp ts = new JwTimestamp();
     ts.Set(x);
     return ts;
 }
Example #16
0
 //# __________ PROTOCOL :: COMPARE (convenience) __________ #//
 public bool IsBefore(JwTimestamp d)
 {
     return CompareTo(d) < 0;
 }
Example #17
0
 public static JwTimestamp CreateNowUtc()
 {
     JwTimestamp ts = new JwTimestamp();
     ts.SetNowUtc();
     return ts;
 }
Example #18
0
 public bool IsOnOrBefore(JwTimestamp d)
 {
     return CompareTo(d) <= 0;
 }
Example #19
0
 public bool HasEnd(JwTimestamp ts)
 {
     return JwUtility.IsEqual(GetEnd(), ts);
 }
Example #20
0
 //# __________ PROTOCOL :: INTERSECTION __________ #//
 /**
  * @see containsInclusive
  */
 public bool Contains(JwTimestamp t)
 {
     return ContainsInclusive(t);
 }
Example #21
0
 public bool HasStart(JwTimestamp ts)
 {
     return JwUtility.IsEqual(GetStart(), ts);
 }
Example #22
0
        public String GetTimeSinceLastLog()
        {
            if( _lastLogTime == null )
            {
                return HandleFirstLogTime();
            }

            JwTimestamp ts = JwTimestamp.CreateNowUtc();

            if( _lastLogTime.IsAfter(ts) )
            {
                WriteToLog("Current time earlier than last time! Resetting!\r\n");
                return HandleFirstLogTime();
            }

            JwDuration d = _lastLogTime.Difference(ts);

            int value = 0;
            String unit = null;
            if( d.IsLessThan(_minuteDuration) )
            {
                value = d.GetSecond();
                unit = "s";
            }
            else if( d.IsLessThan( _hourDuration ) )
            {
                value = d.GetMinute();
                unit = "m";
            }
            else if( d.IsLessThan( _dayDuration ))
            {
                value = d.GetHour();
                unit = "h";
            }
            else
            {
                value = d.GetDay();
                unit = "d";
            }

            String formattedValue = value + "";
            formattedValue = JwUtility.LeftPad(formattedValue, 2, '0');
            StringBuilder sb = new StringBuilder();
            sb.Append("+");
            sb.Append(formattedValue);
            sb.Append(unit);

            _lastLogTime = ts;
            return sb.ToString();
        }
Example #23
0
 public void SetStart(JwTimestamp ts)
 {
     _start = ts;
 }
Example #24
0
 //# __________ PROTOCOL :: UTILITY __________ #//
 public JwDuration Difference(JwTimestamp ts)
 {
     JwDuration dateDifference = ts.GetDate().Difference(_date);
     JwDuration timeDifference = ts.GetTime().Difference(_time);
     JwDuration d = new JwDuration();
     d.Add(dateDifference);
     d.Add(timeDifference);
     return d;
 }
Example #25
0
 public static String FormatIso(JwTimestamp ts)
 {
     return Format(ts, "{yyyy}-{mm}-{dd} {HH24}:{MM}:{SS}");
 }
Example #26
0
 /**
  * Determine if I am between the start and end timestamp, also return true
  * if I am equal to either the start or end timestamp.
  */
 public bool IsBetweenInclusive(JwTimestamp start, JwTimestamp end)
 {
     if ( start != null && IsBefore(start) ) return false;
     if ( end   != null && IsAfter(end) )    return false;
     return true;
 }
Example #27
0
 /**
  * Determine if this interval contains the time.  The test excludes
  * the start and end dates.
  */
 public bool ContainsExclusive(JwTimestamp t)
 {
     if ( t == null ) return false;
     if ( HasStart()  && GetStart().IsOnOrAfter(t) ) return false;
     if ( HasEnd()    && GetEnd().IsOnOrBefore(t) )  return false;
     return true;
 }
Example #28
0
 public static String FormatXsdUtc(JwTimestamp ts)
 {
     return Format(ts, "{yyyy}-{mm}-{dd}T{HH24}:{MM}:{SS}Z");
 }
Example #29
0
        public String HandleFirstLogTime()
        {
            _lastLogTime = JwTimestamp.CreateNowUtc();

            StringBuilder sb = new StringBuilder();
            sb.Append("Began logging at ");
            sb.Append(_lastLogTime.ToString());
            sb.Append(" UTC \r\n");
            WriteToLog(sb.ToString());

            return("+00s");
        }
Example #30
0
 public static String Format_mm_dd_yyyy_HH24_MM(JwTimestamp ts)
 {
     return Format(ts, "{mm}/{dd}/{yyyy} {HH24}:{MM}");
 }