Share via


PrintSystemJobInfo.StartTimeOfDay 屬性

定義

取得一天中印表機開始列印工作的最早時間,以午夜 Coordinated Universal Time (UTC,亦稱為格林威治標準時間 (Greenwich Mean Time,GMT)) 之後經過的分鐘數表示。

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

屬性值

Int32,指定列印工作最早的可能開始時間,以午夜 (UTC) 之後經過的分鐘數表示。 最大值為 1439。

範例

下列範例示範如何在診斷有問題的列印作業過程中使用這個屬性。

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

備註

當作業進入佇列時,這個值會從PrintQueue.StartTimeOfDay裝載PrintQueue的 屬性傳播至每個PrintSystemJobInfo物件。 如果 PrintQueue.StartTimeOfDay 已變更,則早於 PrintQueue.StartTimeOfDay 的任何PrintSystemJobInfo.StartTimeOfDay值會變更為的值PrintQueue.StartTimeOfDay

將作業新增至佇列之後,您可以透過 Microsoft Windows 使用者介面 (UI) 提供新的 StartTimeOfDay 值,前提是其早於 PrintQueue.StartTimeOfDay

如果您不在 UTC 時區,您必須新增或減去 60 的倍數,以取得時區的正確時間。 例如,如果您位於 北美洲 的太平洋時區,且日光節約時間並未生效,則您的當地時間比 UTC 早 8 小時。 如果 StartTimeOfDay 傳回 960,表示 UTC (960/60 = 16:00 (下午 4:00) ,因為 960/60 = 16) 。 若要將此轉換為太平洋時間,您必須減去 480 (= 8 * 60) 分鐘。

您也必須記住,時間會在24小時後變換為零, (亦然;在 1439 第 1439 分鐘之後) 。 如果 傳 StartTimeOfDay 回 120,則表示 UTC 上午 2:00。 若要將此轉換為太平洋時間,您必須減去 480 分鐘,這會導致 -360。 若要取得具有意義的正值,請將負數加到一天中的總分鐘數 1440,導致最終值為 1080 (下午 6:00) 太平洋時間。

如需有助於調整時區的方法,請參閱 TimeZoneTimeSpanDateTime

如果印表機一律可用,則此屬性會在所有時區傳回0。

適用於

另請參閱