Прочетете на английски Редактиране

Споделяне чрез


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.

C#
public int StartTimeOfDay { get; }

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.

C#
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

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

Продукт Версии
.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, 10

See also