PrintQueue.UntilTimeOfDay Property

Definition

Gets or sets the latest time, 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.

C#
public virtual int UntilTimeOfDay { get; set; }

Property Value

The time of day that the printer is no longer 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.

C#
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. ";
        }
    }
}

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 UntilTimeOfDay 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 the 24th hour (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

Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

See also