예제 #1
0
 public static JwTimestamp CreateNowUtc(int utcOffset)
 {
     JwTimestamp ts = new JwTimestamp();
     ts.SetNowUtc();
     ts.SubtractHours(utcOffset);
     return ts;
 }
예제 #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;
 }
예제 #3
0
 public String Format(JwTimestamp ts)
 {
     return JwUtility.Format(
         getFormat(),
         _datePolicy.format(ts.GetDate()),
         _timePolicy.format(ts.GetTime()));
 }
예제 #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;
 }
예제 #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;
 }
예제 #6
0
 public JwTimestamp InferActualDepartureFromActualArrival(JwTimestamp actualArrival)
 {
     JwTimestamp ts = actualArrival.GetTimestampCopy();
     ts.AddDuration(GetTimezoneOffset());
     ts.SubtractDuration(GetTransitDuration());
     return ts;
 }
예제 #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;
        }
예제 #8
0
 public JwTimestamp ComputeScheduledDepartureLocalTimestampFromScheduledArrival(JwTimestamp scheduledArrivalTs)
 {
     JwTimestamp ts = scheduledArrivalTs.GetTimestampCopy();
     ts.SubtractDuration( GetTransitDuration());
     ts.SubtractDuration( GetTimezoneOffset());
     return ts;
 }
예제 #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());
 }
예제 #10
0
 public bool IsOnOrAfter(JwTimestamp d)
 {
     return CompareTo(d) >= 0;
 }
예제 #11
0
 //# __________ PROTOCOL :: CONTRUCTOR __________ #//
 public JwTimestampInterval()
 {
     _start = null;
     _end = null;
 }
예제 #12
0
 public void SetEnd(JwTimestamp ts)
 {
     _end = ts;
 }
예제 #13
0
 public bool IsAfter(JwTimestamp d)
 {
     return CompareTo(d) > 0;
 }
예제 #14
0
        //# __________ PROTOCOL :: TESTING __________ #//
        public bool HasArrivedEarly(JwTimestamp scheduledArrivalTs)
        {
            if(ActualArrivalLocalTs == null) return false;

            return ActualArrivalLocalTs.IsBefore(scheduledArrivalTs);
        }
예제 #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;
 }
예제 #16
0
 //# __________ PROTOCOL :: COMPARE (convenience) __________ #//
 public bool IsBefore(JwTimestamp d)
 {
     return CompareTo(d) < 0;
 }
예제 #17
0
 public static JwTimestamp CreateNowUtc()
 {
     JwTimestamp ts = new JwTimestamp();
     ts.SetNowUtc();
     return ts;
 }
예제 #18
0
 public bool IsOnOrBefore(JwTimestamp d)
 {
     return CompareTo(d) <= 0;
 }
예제 #19
0
 public bool HasEnd(JwTimestamp ts)
 {
     return JwUtility.IsEqual(GetEnd(), ts);
 }
예제 #20
0
 //# __________ PROTOCOL :: INTERSECTION __________ #//
 /**
  * @see containsInclusive
  */
 public bool Contains(JwTimestamp t)
 {
     return ContainsInclusive(t);
 }
예제 #21
0
 public bool HasStart(JwTimestamp ts)
 {
     return JwUtility.IsEqual(GetStart(), ts);
 }
예제 #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();
        }
예제 #23
0
 public void SetStart(JwTimestamp ts)
 {
     _start = ts;
 }
예제 #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;
 }
예제 #25
0
 public static String FormatIso(JwTimestamp ts)
 {
     return Format(ts, "{yyyy}-{mm}-{dd} {HH24}:{MM}:{SS}");
 }
예제 #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;
 }
예제 #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;
 }
예제 #28
0
 public static String FormatXsdUtc(JwTimestamp ts)
 {
     return Format(ts, "{yyyy}-{mm}-{dd}T{HH24}:{MM}:{SS}Z");
 }
예제 #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");
        }
예제 #30
0
 public static String Format_mm_dd_yyyy_HH24_MM(JwTimestamp ts)
 {
     return Format(ts, "{mm}/{dd}/{yyyy} {HH24}:{MM}");
 }