Beispiel #1
0
 /**
  * Create a date from a java.util.Date
  */
 public static JwDate CreateDate(DateTime e)
 {
     JwDate d;
     d = new JwDate();
     d.Set(e);
     return d;
 }
Beispiel #2
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;
 }
Beispiel #3
0
 //# __________ PROTOCOL :: INSTANCE CREATION __________ #//
 public static JwDateInterval CreateDateInterval(JwDate start, JwDate end)
 {
     JwDateInterval di;
     di = new JwDateInterval();
     di.Start = start;
     di.End = end;
     return di;
 }
Beispiel #4
0
        //# __________ PROTOCOL :: MISC __________ #//
        /**
         * Determine the difference between two dates.  The resultant
         * array contains three elements { years, months, days }.
         */
        public static int[] Difference(JwDate fromDate, JwDate toDate)
        {
            if ( fromDate.GetOrdinal() >= toDate.GetOrdinal() )
                return new int[]
                {
                    0, 0, 0
                };

            int fromYear   = fromDate.GetYear();
            int fromMonth  = fromDate.GetMonth();
            int fromDay    = fromDate.GetDay();
            int toYear    = toDate.GetYear();
            int toMonth   = toDate.GetMonth();
            int toDay     = toDate.GetDay();
            int diffYears  = toYear - fromYear;
            int diffMonths = toMonth - fromMonth;
            int diffDays   = toDay - fromDay;

            if ( diffDays < 0 )
            {
                diffDays += GetDaysInYearMonth(fromYear, fromMonth);
                diffMonths--;
            }
            if ( diffMonths < 0 )
            {
                diffMonths += 12;
                diffYears--;
            }
            if ( fromYear < 0 && toYear > 0 ) diffYears--;

            if ( diffYears < 0 )
            {
                diffYears = 0;
                diffMonths = 0;
                diffDays = 0;
            }
            return new int[] {diffYears, diffMonths, diffDays};
        }
Beispiel #5
0
        public void HandleIdentifyTruck(VmScheduledTruck scheduledTruck, JwDate scheduledArrivalDate)
        {
            JwTimestamp expectedArrivalTs = scheduledTruck.GetScheduledArrivalTimestampForScheduledArrivalDate(scheduledArrivalDate);
            VmTruck truck = scheduledTruck.CreateTruckForScheduledArrival(expectedArrivalTs);

            truck.ActualDepartureLocalTs = truck.ExpectedDepartureLocalTs.GetTimestampCopy();
            truck.ActualArrivalLocalTs =  expectedArrivalTs.GetTimestampCopy();

            Truck = truck;

            JwTimestamp nowLocalTs = JwTimestamp.CreateNowLocal();

            if( nowLocalTs.IsBefore(truck.ActualArrivalLocalTs) )
            {

                truck.ActualArrivalLocalTs = nowLocalTs;
                //err - removed at request of AA, the only user of this feature.  Waiting for beta testing
                //completion (and acceptance) to remove the following line.
            //                truck.ActualDepartureLocalTs = scheduledTruck.InferActualDepartureFromActualArrival(nowLocalTs);

                JwDuration tooEarlyThreshold = nowLocalTs.Difference(expectedArrivalTs);
                if( tooEarlyThreshold.GetTotalMinutes() > VmProperties.Default.GetEarlyTruckAllowanceMinutes() )
                {
                    ShowWarnOfEarlyArrivalPanel();
                    return;
                }
            }

            ShowActualsPanel();
        }
Beispiel #6
0
 //# __________ PROTOCOL :: STATIC __________ #//
 public static String FormatDate(JwDate date, String format)
 {
     return new JwDateFormatter(format).Format(date);
 }
Beispiel #7
0
 //# __________ PROTOCOL :: FORMAT __________ #//
 public String Format(JwDate d)
 {
     return JwDateUtility.Format(d, _format);
 }
Beispiel #8
0
 public static String FormatAsIsoDate(JwDate date)
 {
     JwDatePolicyIso policy = new JwDatePolicyIso();
     return policy.format(date);
 }
 public void FindScheduledFlights(JwDate departureDate)
 {
     _destinationAirportCodes = null;
     _scheduledFlights.Clear();
     _scheduledFlights.AddRange( PickerEngine.GetScheduledFlightsForDate(departureDate));
 }
 public void FindScheduledFlights(JwDate arrivalDate)
 {
     _originAirportCodes = null;
     _scheduledFlights.Clear();
     _scheduledFlights.AddRange( PickerEngine.GetScheduledFlightsForDate(arrivalDate));
 }
 //# __________ PROTOCOL :: PUBLIC (OTHER) __________ #//
 public JwList<VmPlannedRouteConfiguration> GetPlannedRouteConfigurations(JwDate plannedRouteDate)
 {
     JwList<VmPlannedRouteConfiguration> v = new JwList<VmPlannedRouteConfiguration>();
     foreach(VmPlannedRouteConfiguration config in GetPlannedRouteConfigurations() )
     {
         if( config.IncludesDate(plannedRouteDate) ) v.Add(config);
     }
     return v;
 }
Beispiel #12
0
        //# __________ PROTOCOL :: PUBLIC __________ #//
        public void AssignFlight(VmScheduledFlight sf, JwDate date)
        {
            VmFlight f = new VmFlight();
            f.Date = date;
            f.ScheduledFlight = sf;
            VmFlight existingFlight = VmAirportData.Default.AirportOutputData.FlightFile.GetFlight(f);
            if( existingFlight != null )
            {
                f = existingFlight;
            }
            else
            {
                f.Id = VmAirportData.Default.AirportOutputData.IdentityFile.GetNextIdentity();
                VmAirportData.Default.AirportOutputData.FlightFile.Append(f);
            }
            Flight = f;

            JwTimestamp now = JwTimestamp.CreateNowLocal();
            if( Flight.GetScheduledDepartureTs().IsBefore(now) )
                ShowWarnLateDeparturePanel();
            else
                DoExitEvent();
        }
Beispiel #13
0
        public VmTruck CreateTruckForScheduledArrival(JwDate scheduledArrivalDate)
        {
            JwTimestamp expectedArrivalLocalTs = GetScheduledArrivalTimestampForScheduledArrivalDate(scheduledArrivalDate);

            return CreateTruckForScheduledArrival(expectedArrivalLocalTs);
        }
Beispiel #14
0
 /**
  * Format a date, e.g.: Jan 31, 1985 -> 19850131.
  */
 public static String Format_yyyymmdd(JwDate d)
 {
     return "" +
         Pad4(d.GetYear()) +
         Pad2(d.GetMonth()) +
         Pad2(d.GetDay());
 }
Beispiel #15
0
 private static int GetShortYear(JwDate d)
 {
     return d.GetYear() % 100;
 }
Beispiel #16
0
 /**
  * Format a date, e.g.: Jan 31, 1985 -> 1/31/1985
  */
 public static String Format_m_dd_yy(JwDate d)
 {
     return "" +
         d.GetMonth() +
         JwTimeConstants.DATE_SEPARATOR +
         Pad2(d.GetDay()) +
         JwTimeConstants.DATE_SEPARATOR +
         Pad2(GetShortYear(d));
 }
Beispiel #17
0
 /**
  * Format a date, e.g.: Jan 31, 1985 -> 01/85
  */
 public static String Format_mm_yy(JwDate d)
 {
     return "" +
         Pad2(d.GetMonth()) +
         JwTimeConstants.DATE_SEPARATOR +
         Pad4(d.GetYear());
 }
Beispiel #18
0
 /**
  * Format a date in XSD format.
  */
 public static String FormatXsd(JwDate d)
 {
     return JwDateFormatter.FormatDate(d, "{yyyy}-{mm}-{dd}");
 }
Beispiel #19
0
        public JwList<VmScheduledFlight> GetScheduledFlightsForDate(JwDate departureDate)
        {
            JwList<VmScheduledFlight> v = GetScheduledFlights().SelectAll(
                delegate(VmScheduledFlight sf)
                {
                    if( ! sf.EffectiveDateInterval.Contains(departureDate) ) return false;
                    return sf.Frequency.WillDepartOn(departureDate.GetDayOfWeek());
                });

               if(HasFlight()) v.Add(Flight.ScheduledFlight);
               return v;
        }
        public VmPlannedRoute GetPlannedRoute(JwDate plannedRouteDate, String routeIndexNumber)
        {
            JwList<VmPlannedRouteConfiguration> configs = GetPlannedRouteConfigurations(plannedRouteDate);
            if( configs.IsEmpty() ) return null;

            foreach( VmPlannedRouteConfiguration config in configs)
            {
                VmPlannedRoute pr = config.GetPlannedRoute(this, routeIndexNumber);
                if( pr != null ) return pr;
            }
            return null;
        }
Beispiel #21
0
 public void ShowEnterFlightPanel(JwDate scheduledDepartureDate, String destinationAirportCode)
 {
     VmFpkEnterFlightPanel p = GetEnterFlightPanel();
     p.ScheduledDepartureDate = scheduledDepartureDate;
     p.DestinationAirportCode = destinationAirportCode;
     Show(p);
 }
Beispiel #22
0
 public String format(JwDate d)
 {
     return _formatter.Format(d);
 }
Beispiel #23
0
 public JwTimestamp ComputeScheduledDepartureLocalTimestampFromScheduledArrival(JwDate scheduledArrivalDt)
 {
     JwTimestamp scheduledArrivalTs = GetScheduledArrivalTimestampForScheduledArrivalDate(scheduledArrivalDt);
     return ComputeScheduledDepartureLocalTimestampFromScheduledArrival(scheduledArrivalTs);
 }
Beispiel #24
0
        //# __________ PROTOCOL :: FORMAT __________ #//
        /**
         * I provide a very simple, and non-optimized, facility for formatting
         * dates in a variety of formats.  Valid format codes are:
         * {d}    : day of month (1-31)
         * {dd}   : day of month (01-31)
         * {ddd}  : weekday abbreviation (Sun-Sat)
         * {dddd} : weekday name (Sunday-Saturday)
         * {m}    : month (1-12)
         * {mm}   : month (01-12)
         * {mmm}  : month abbreviation (Jan-Dec)
         * {mmmm} : month name (January-December)
         * {yy}   : year (00-99)
         * {yyyy} : year (1800-9999)
         */
        public static String Format(JwDate d, String format)
        {
            String s = format;
            s = JwUtility.ReplaceAll(s, "{mmmm}",    JwDateUtility.GetMonthName(d.GetMonth()));
            s = JwUtility.ReplaceAll(s, "{mmm}",     JwDateUtility.GetMonthAbbreviation(d.GetMonth()));
            s = JwUtility.ReplaceAll(s, "{mm}",      Pad2(d.GetMonth()));
            s = JwUtility.ReplaceAll(s, "{m}",       d.GetMonth() + "");

            s = JwUtility.ReplaceAll(s, "{dddd}",    JwDateUtility.GetDayOfWeekName(d.GetDayOfWeek()));
            s = JwUtility.ReplaceAll(s, "{ddd}",     JwDateUtility.GetDayOfWeekAbbreviation(d.GetDayOfWeek()));
            s = JwUtility.ReplaceAll(s, "{dd}",      Pad2(d.GetDay()));
            s = JwUtility.ReplaceAll(s, "{d}",       d.GetDay() + "");

            s = JwUtility.ReplaceAll(s, "{yyyy}",    d.GetYear() + "");
            s = JwUtility.ReplaceAll(s, "{yy}",      Pad2(GetShortYear(d)));
            return s;
        }
Beispiel #25
0
 public JwTimestamp GetScheduledArrivalTimestampForScheduledArrivalDate(JwDate arrivalDate)
 {
     return JwTimestamp.CreateTimestamp(
         arrivalDate,
         ArrivalTime);
 }
Beispiel #26
0
        public bool WillDepartOn(JwDate d)
        {
            int dayOfWeek = d.GetDayOfWeek();

            if( ( dayOfWeek == JwDayOfWeek.SUNDAY )     && IsSunday() ) return true;
            if( ( dayOfWeek == JwDayOfWeek.MONDAY )     && IsMonday() ) return true;
            if( ( dayOfWeek == JwDayOfWeek.TUESDAY )    && IsTuesday() ) return true;
            if( ( dayOfWeek == JwDayOfWeek.WEDNESDAY )  && IsWednesday() ) return true;
            if( ( dayOfWeek == JwDayOfWeek.THURSDAY )   && IsThursday() ) return true;
            if( ( dayOfWeek == JwDayOfWeek.FRIDAY )     && IsFriday() ) return true;
            if( ( dayOfWeek == JwDayOfWeek.SATURDAY )   && IsSaturday() ) return true;

            return false;
        }
        public VmPlannedRouteCloseOut GetPlannedRouteCloseOut(JwDate plannedRouteDate, String routeIndexNumber)
        {
            JwList<VmPlannedRouteConfiguration> configs = GetPlannedRouteConfigurations(plannedRouteDate);
            if( configs.IsEmpty() ) return null;

            foreach( VmPlannedRouteConfiguration config in configs)
            {
                VmPlannedRouteCloseOut closeOut = config.GetPlannedRouteCloseOut(this, routeIndexNumber);
                if( closeOut != null ) return closeOut;
            }
            return null;
        }
        public JwList<VmScheduledArrivingFlight> GetScheduledFlightsForDate(JwDate arrivalDate)
        {
            JwList<VmScheduledArrivingFlight> v = GetScheduledFlights().SelectAll(
                delegate(VmScheduledArrivingFlight sf)
                {
                    return sf.IsApplicableForArrivalDate(arrivalDate);
                });

               return v;
        }
 //# __________ PROTOCOL :: TESTING __________ #//
 public bool IncludesDate(JwDate date)
 {
     if( EffectiveStartDate.IsAfter(date) ) return false;
     if( EffectiveEndDate.IsBefore(date) ) return false;
     return true;
 }
 public void ShowEnterFlightPanel(JwDate scheduledDepartureDate, String originAirportCode)
 {
     VmArrivingFlightEnterPanel p = GetEnterFlightPanel();
     p.ScheduledDepartureDate = scheduledDepartureDate;
     p.OriginAirportCode = originAirportCode;
     Show(p);
 }