asctime_s, wasctime_s

Aus RAD Studio
Wechseln zu: Navigation, Suche

Nach oben zu Time.h - Index


Header-Datei

time.h

Kategorie

Uhrzeit- und Datumsroutinen

Prototyp

errno_t asctime_s(char *s, rsize_t maxsize, const struct tm *tmPtr);
errno_t wasctime_s(wchar_t *s, rsize_t maxsize, const struct tm *tmPtr);

Beschreibung

Ersetzt asctime und fügt Sicherheitserweiterungen hinzu.

asctime_s konvertiert Datum und Zeit in einen ASCII-String.

wasctime_s konvertiert Datum und Zeit in einen String des Typs wchar_t.

asctime_s und wasctime_s konvertieren in einer Struktur gespeicherte Datums- und Zeitwerte in einen 26 Zeichen langen Einzelbyte- oder Multibyte-String der folgenden Form:

Mon Nov 21 11:31:54 1983\n\0

Alle Felder haben eine konstante Breite. Die ausgegebenen Strings für Wochentag und Monat entsprechen Folgendem:

tm-Parameter Gültiger Bereichswert Ausgabe

tm.mon (Monat) 0-11 0=Jan, 1=Feb usw.

tm.day (Wochentag) 0-6 0=Son, 1=Mon usw.

Bei einer Verletzung von Laufzeiteinschränkungen wird s[0] auf Null gesetzt.

Rückgabewert

asctime_s und wasctime_s geben bei Erfolg Null, ansonsten Nicht-Null zurück.

Beispiel

#include <string.h>
#include <time.h>
#include <stdio.h>
int main(void)
{
    struct tm t; char str[80]; 
    /* Sample loading of tm structure  */ 
    t.tm_sec    = 1;  /* Seconds */ 
    t.tm_min    = 30; /* Minutes */ 
    t.tm_hour   = 9;  /* Hour */ 
    t.tm_mday   = 22; /* Day of the Month  */ 
    t.tm_mon    = 11; /* Month */ 
    t.tm_year   = 56; /* Year - does not include century */ 
    t.tm_wday   = 4;  /* Day of the week  */ 
    t.tm_yday   = 0;  /* Does not show in asctime */ 
    t.tm_isdst  = 0;  /* Is Daylight SavTime; does not show in asctime */ 
    /* Converts structure to null-terminated string */ 
    asctime_s(str, 50, &t); 
    printf("%s\n", str); 
    return 0; 
}

Portabilität

POSIX Win32 ANSI C ANSI C++

asctime_s

+

+

+

+

wasctime_s

+

Siehe auch