PrintQueue.UntilTimeOfDay Propiedad

Definición

Obtiene o establece la última hora del día, expresada como el número de minutos después de la medianoche de la hora universal coordinada (UTC) (también denominada hora del meridiano de Greenwich [GMT]), a la que la impresora imprimirá un trabajo.

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

Valor de propiedad

Hora del día a la que la impresora ya no está disponible, expresada como el número de minutos después de medianoche (UTC). El valor máximo es 1439. Cuando se instala una impresora por primera vez mediante el Asistente para agregar impresoras de Microsoft Windows, la impresora tiene como valor predeterminado estar disponible todo el tiempo y esta propiedad devuelve 0 en todas las zonas horarias.

Ejemplos

En el ejemplo siguiente se muestra cómo usar esta propiedad para determinar si una impresora está disponible en el momento actual.

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

Comentarios

Si no está en la zona horaria UTC, debe agregar o restar múltiplos de 60 para establecer o obtener la hora correcta para la zona horaria. Por ejemplo, si se encuentra en la zona horaria del Pacífico de Norteamérica y el horario de verano no está en vigor, la hora local es de 8 horas anteriores a las UTC. Para establecer UntilTimeOfDay en 12 a. m. en la zona horaria, establézcala en 8 a. m. UTC, que es 480 (= 8 * 60). También debe recordar que el tiempo pasa a cero después de la 24ª hora (el minuto 1439). Para establecerla en 6 p.m. en la zona horaria, establézcala en 2 a. m. UTC, que es 120 (= 2 * 60). Consulte TimeZoneclases , TimeSpany DateTime para obtener métodos útiles de manipulación de zonas horarias.

Si la impresora siempre está disponible, esta propiedad devuelve 0 en todas las zonas horarias.

Se aplica a

Consulte también