ערוך

שתף באמצעות


PrintQueue.StartTimeOfDay Property

Definition

Gets or sets 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 printer will print a job.

public:
 virtual property int StartTimeOfDay { int get(); void set(int value); };
public virtual int StartTimeOfDay { get; set; }
member this.StartTimeOfDay : int with get, set
Public Overridable Property StartTimeOfDay As Integer

Property Value

The time of day that the printer first becomes available, expressed as the number of minutes after midnight (UTC). The maximum value is 1439. When a printer is first installed by using the Microsoft Windows Add Printer Wizard, the printer defaults to being available all the time, and this property returns 0 in all time zones.

Examples

The following example shows how to use this property to determine whether a printer is available at the present time.

private: 
   static void ReportAvailabilityAtThisTime (System::String^% statusReport, System::Printing::PrintQueue^ pq) 
   {
      if (pq->StartTimeOfDay != pq->UntilTimeOfDay)
      {
         System::DateTime utcNow = DateTime::UtcNow;
         System::Int32 utcNowAsMinutesAfterMidnight = (utcNow.TimeOfDay.Hours * 60) + utcNow.TimeOfDay.Minutes;

         // If now is not within the range of available times . . .
         if (!((pq->StartTimeOfDay < utcNowAsMinutesAfterMidnight) && (utcNowAsMinutesAfterMidnight < pq->UntilTimeOfDay)))
         {
            statusReport = statusReport + " Is not available at this time of day. ";
         }
      }
   };
private static void ReportAvailabilityAtThisTime(ref String statusReport, PrintQueue pq)
{
    if (pq.StartTimeOfDay != pq.UntilTimeOfDay) // If the printer is not available 24 hours a 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 (!((pq.StartTimeOfDay < utcNowAsMinutesAfterMidnight) 
           &&
           (utcNowAsMinutesAfterMidnight < pq.UntilTimeOfDay)))
        {
            statusReport = statusReport + " Is not available at this time of day. ";
        }
    }
}
Private Shared Sub ReportAvailabilityAtThisTime(ByRef statusReport As String, ByVal pq As PrintQueue)
    If pq.StartTimeOfDay <> pq.UntilTimeOfDay Then ' If the printer is not available 24 hours a 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((pq.StartTimeOfDay < utcNowAsMinutesAfterMidnight) AndAlso (utcNowAsMinutesAfterMidnight < pq.UntilTimeOfDay)) Then
            statusReport = statusReport & " Is not available at this time of day. "
        End If
    End If
End Sub

Remarks

If you are not in the UTC time zone, you must add or subtract multiples of 60 to set or 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. To set StartTimeOfDay to 12 AM in your time zone, you set it to 8 AM UTC, which is 480 (= 8 * 60). You also must remember that time rolls over to zero after 24 hours (that is; after the 1439th minute). To set it to 6 PM in your time zone, you set it to 2 AM UTC, which is 120 (= 2 * 60). See TimeZone, TimeSpan, and DateTime classes for helpful time zone manipulating methods.

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

Applies to

See also