Redigera

Dela via


PrintSystemJobInfo.UntilTimeOfDay Property

Definition

Gets the last time of day, expressed as the number of minutes after midnight Coordinated Universal Time (UTC) (also called Greenwich Mean Time [GMT]), that the print job can begin printing.

public:
 property int UntilTimeOfDay { int get(); };
public int UntilTimeOfDay { get; }
member this.UntilTimeOfDay : int
Public ReadOnly Property UntilTimeOfDay As Integer

Property Value

An Int32 that specifies the last time that the job can print, expressed as the number of minutes after midnight (UTC). The maximum value is 1439.

Examples

The following example shows how to use this property as part of the process of diagnosing a problematic print job.

static Boolean ReportAvailabilityAtThisTime (PrintSystemJobInfo^ theJob) 
{
   Boolean available = true;
   if (theJob->StartTimeOfDay != theJob->UntilTimeOfDay)
   {
      DateTime utcNow = DateTime::UtcNow;
      Int32 utcNowAsMinutesAfterMidnight = (utcNow.TimeOfDay.Hours * 60) + utcNow.TimeOfDay.Minutes;

      // If "now" is not within the range of available times . . .
      if (!((theJob->StartTimeOfDay < utcNowAsMinutesAfterMidnight) && (utcNowAsMinutesAfterMidnight < theJob->UntilTimeOfDay)))
      {
         available = false;
      }
   }
   return available;
}
private static Boolean ReportAvailabilityAtThisTime(PrintSystemJobInfo theJob)
{
    Boolean available = true;
    if (theJob.StartTimeOfDay != theJob.UntilTimeOfDay) // If the job cannot be printed at all times of day
    {
        DateTime utcNow = DateTime.UtcNow;
        Int32 utcNowAsMinutesAfterMidnight = (utcNow.TimeOfDay.Hours * 60) + utcNow.TimeOfDay.Minutes;

        // If "now" is not within the range of available times . . .
        if (!((theJob.StartTimeOfDay < utcNowAsMinutesAfterMidnight) 
           && 
           (utcNowAsMinutesAfterMidnight < theJob.UntilTimeOfDay)))
        {
            available = false;
        }
    }
    return available;
}//end ReportAvailabilityAtThisTime
Private Shared Function ReportAvailabilityAtThisTime(ByVal theJob As PrintSystemJobInfo) As Boolean
    Dim available As Boolean = True
    If theJob.StartTimeOfDay <> theJob.UntilTimeOfDay Then ' If the job cannot be printed at all times of day
        Dim utcNow As Date = Date.UtcNow
        Dim utcNowAsMinutesAfterMidnight As Int32 = (utcNow.TimeOfDay.Hours * 60) + utcNow.TimeOfDay.Minutes

        ' If "now" is not within the range of available times . . .
        If Not((theJob.StartTimeOfDay < utcNowAsMinutesAfterMidnight) AndAlso (utcNowAsMinutesAfterMidnight < theJob.UntilTimeOfDay)) Then
            available = False
        End If
    End If
    Return available
End Function 'end ReportAvailabilityAtThisTime

Remarks

This value is propagated to each PrintSystemJobInfo object from the PrintQueue.UntilTimeOfDay property of the hosting PrintQueue at the time the job enters the queue. If PrintQueue.UntilTimeOfDay is changed, then any PrintSystemJobInfo.UntilTimeOfDay value that is later than PrintQueue.UntilTimeOfDay is changed to the value of PrintQueue.UntilTimeOfDay.

After the job is added to the queue, it can be given a new UntilTimeOfDay value through the Microsoft Windows user interface (UI), provided that it is not later than PrintQueue.UntilTimeOfDay.

If you are not in the UTC time zone, you must add or subtract multiples of 60 to get the correct time for your time zone. For example, if you are in the Pacific Time Zone of North America and daylight savings time is not in effect, then your local time is 8 hours earlier than UTC. If UntilTimeOfDay returns 960, that means 16:00 (4:00 PM) in UTC (because 960/60 = 16). To convert this to Pacific Time, you must subtract 480 (= 8 * 60) minutes.

You also must remember that time rolls over to zero after 24 hours (that is; after the 1439th minute). If UntilTimeOfDay returns 120, that means 2:00 AM in UTC. To convert this to Pacific Time, you must subtract 480 minutes, which results in -360. To get a positive value that has meaning, add the negative number to the total minutes in a day, 1440, resulting in a final value of 1080 (6:00 PM) Pacific Time.

See TimeZone, TimeSpan, and DateTime for methods that help make time-zone adjustments.

If the printer is always available, then this property returns 0 in all time zones.

Applies to

See also