wcsftime

Converts the specified date and time into a formatted wide-character string.

Library:LibC
Classification:ANSI
Service:Characters and Strings

Syntax

  #include <wchar.h> 
   
  size_t  wcsftime (
     wchar_t           *wcs,
     size_t             maxsize,
     const wchar_t     *format,
     const struct tm   *timeptr);
  

Parameters

wcs

(OUT) Points to the character array for the converted wide-character string.

maxsize

(IN) Specifies the maximum number of wide characters that can be placed in the array.

format

(IN) Points to the format control string.

timeptr

(IN) Points to the tm structure to convert. (For a description, see Volume 2).

Return Values

If the number of wide characters to be placed into the array is less than the value specified by the maxsize parameter, the function returns the number of wide characters placed into the array pointed to by the wcs parameter (not including the null-terminating wide character). Otherwise, it returns 0 and the contents of the array are unspecified.

Remarks

The wcsftime function formats the time in the timeptr parameter into the array pointed to by the wcs parameter according to the format parameter.

Local timezone information is used.

The format parameter string is a null-terminated string. It consists of zero or more directives and ordinary characters. A directive consists of a % character followed by a character that determines the substitution that is to take place. All ordinary characters are copied unchanged into the array. No more than the number of characters specified by the maxsize parameter are placed in the array.

The following conversion specifications are supported:

Directive

Substitution

%a

Replaced by the locale's abbreviated weekday name

%A

Replaced by the locale's full weekday name

%b

Replaced by the locale's abbreviated month name

%B

Replaced by the locale's full month name

%c

Replaced by the locale's appropriate date and time representation

%C

Replaced by the century number (“19” if year is 1997)

%d

Replaced by the day of the month as a decimal number (01-31)

%D

Replaced by the date in the format mm/dd/yy (POSIX)

%h

Replaced by the locale's abbreviated month name (POSIX)

%H

Replaced by the hour (24-hour clock) as a decimal number (00-23)

%I

Replaced by the hour (12-hour clock) as a decimal number (01-12)

%j

Replaced by the day of the year as a decimal number (001-366)

%m

Replaced by the month as a decimal number (01-12)

%M

Replaced by the minute as a decimal number (00-59)

%n

Replaced by the newline character (POSIX)

%p

Replaced by the locale's equivalent of either a.m. or p.m. notation

%r

Replaced by the time in a.m. and p.m. notation

%R

Replaced by time in 24-hour notation.

%S

Replaced by the second as a decimal number (00-59)

%t

Replaced by the tab character (POSIX)

%T

Replaced by the 24-hour clock time in the format hh:mm:ss (POSIX)

%U

Replaced by the week number of the year as a decimal number (00-53) where the first Sunday in January is the first day of the week 1

%w

Replaced by the weekday as a decimal number (0-6) where 0 is Sunday

%W

Replaced by the week number of the year as a decimal number (00-53). If the week containing January 1 has four or more days of the new year, it is considered week 1. Otherwise it is the last week of the previous year, and the next week is week 1.

%x

Replaced by the locale's appropriate date representation

%X

Replaced by the locale's appropriate time representation

%y

Replaced by the last two digits of the year as a decimal number (00-99)

%Y

Replaced by the year as a four-digit decimal number

%Z

Replaced by the time zone name or abbreviation, or by no characters if no time zone exists

%%

Replaced by the % character

See Also

strftime