Επεξεργασία

Κοινή χρήση μέσω


PrintSystemJobInfo.StartTimeOfDay Property

Definition

Gets the earliest 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 StartTimeOfDay { int get(); };
public int StartTimeOfDay { get; }
member this.StartTimeOfDay : int
Public ReadOnly Property StartTimeOfDay As Integer

Property Value

An Int32 specifying the earliest possible start time for the print job, 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.StartTimeOfDay property of the hosting PrintQueue at the time the job enters the queue. If PrintQueue.StartTimeOfDay is changed, then any PrintSystemJobInfo.StartTimeOfDay value that is earlier than PrintQueue.StartTimeOfDay is changed to the value of PrintQueue.StartTimeOfDay.

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

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 StartTimeOfDay 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 StartTimeOfDay 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