ascftime man page on DigitalUNIX

Man page or keyword search:  
man Server   12896 pages
apropos Keyword Search (all sections)
Output format
DigitalUNIX logo
[printable version]

strftime(3)							   strftime(3)

NAME
       strftime, cftime, ascftime- Converts a date and time to a string

SYNOPSIS
       #include <time.h>

       size_t  strftime	 (char	*s,  size_t maxsize, const char *format, const
       struct tm *timeptr);

       int cftime (char *s, char *format, const time_t *clock);

       int ascftime (char *s, const char *format, const struct tm *timeptr);

LIBRARY
       SVR4 Library (libsvr4)

PARAMETERS
       Points to the array containing the output date and time string.	Speci‐
       fies  the  maximum  number of bytes or wide characters to be written to
       the array pointed to by the s parameter.	 Points to a sequence of char‐
       acters  that  specify  the format of the date and time to be written to
       the output string or wide-character string.  See the  DESCRIPTION  sec‐
       tion for more information.  Points to a type tm structure that contains
       broken-down time information.

DESCRIPTION
       The strftime(), ascftime(), and	cftime()  functions  place  characters
       into  the  array	 pointed  to  by  the s parameter as controlled by the
       string pointed to by the format. The format string consists of zero  or
       more  directives	 and  ordinary	characters.  All  ordinary  characters
       (including the terminating null character) are  copied  unchanged  into
       the  array.  For strftime(), no more than maxsize characters are placed
       into the array.

       If format is (char *)0, then the locale's default format is  used.  For
       strftime()  function  the  default  format  is  the  same  as "%c", for
       cftime() and ascftime() functions, the default format is	 the  same  as
       "%C".  cftime() and ascftime() functions, first try to use the value of
       the environment variable CFTIME, and it that is undefined or empty, the
       default format is used.

       Each  directive	is  replaced by appropriate characters as described in
       the following list. The appropriate characters are  determined  by  the
       LC_TIME category of the program's locale and by the values contained in
       the structure pointed to by timeptr for strftime() and ascftime() func‐
       tions and by the time represented by clock for cftime() function.

       same  as % locale's abbreviated weekday name locale's full weekday name
       locale's abbreviated month  name	 locale's  full	 month	name  locale's
       appropriate  date and time representation locale's date and time repre‐
       sentation as produced by date (1)

       day of the month (01 - 31) date as %m/%d/%y The day of the month (1-31;
       single  digits  as preceded by a blank) locale's abbreviated month name
       hour ( 00 - 23 ) hour ( 01 -12 ) day number of year ( 001 - 366 ) month
       number  ( 01 - 12 ) minute (00 - 59 ) same as 1p locale's equivalent of
       either AM or PM time as %I:%M:%S [AM|PM] time as %H:%M seconds (	 00  -
       61 ), allows for leap seconds insert a tab time as %H:%M:%S week number
       of year ( 00 - 53 ), Sunday is the first day of week 1 weekday number (
       0  -  6	),  Sunday  = 0 week number of year ( 00 - 53 ), Monday is the
       first day of week 1 locale's appropriate date  representation  locale's
       appropriate time representation year within century ( 00 - 99 ) year as
       ccyy ( eg. 1986) time zone name or no characters if no time zone exists

       The difference between %U and %W lies in which day is  counted  as  the
       first of the week. Week number 01 is the first week in January starting
       with a Sunday for %U or a Monday for %W. Week number 00 contains	 those
       days  before  the  first	 Sunday	 or  Monday  in January for %U and %W,
       respectively.

       If the total number of resulting characters including  the  terminating
       null character is not more than maxsize, strftime(), cftime() and ascf‐
       time() functions return the number of characters placed into the	 array
       pointed	to  by	s not including the terminating null character. Other‐
       wise, zero is returned and the contents of the array are indeterminate.
       cftime()	 and  ascftime()  functions  return  the  number of characters
       placed into the array pointed to by s  not  including  the  terminating
       null character.

       Selecting the Output's Language

       By default, the output of strftime(), cftime() and ascftime() functions
       appear in US English. The user can request that	the  output  of	 strf‐
       time(),	cftime()  or ascftime() functions be in a specific language by
       setting the locale for category LC_TIME in set locale.

       Timezone

       The timezone is taken from the environment variable TZ [see ctime  (3C)
       for a description of TZ].

EXAMPLES
       The following example uses strftime() to display the current date:

       #include	  <time.h>  #include  <locale.h>  #include  <stdio.h>  #define
       SLENGTH 80

       main() {
	   char nowstr[SLENGTH];
	   time_t nowbin;
	   const struct tm *nowstruct;

	   (void)setlocale(LC_ALL, "");

	   if (time(&nowbin) == (time_t) - 1)
	       printf("Could not get time of day from time()\n");

	   nowstruct = localtime(&nowbin);

	   if (strftime(nowstr, SLENGTH, "%A %x", nowstruct) == (size_t) 0)
	       printf("Could not get string from strftime()\n");

	   printf("Today's date is %s\n", nowstr); }

NOTES
       The %S seconds field can contain a value up to 61 seconds  rather  than
       up  to  59  seconds  to	allow leap seconds that are sometimes added to
       years to keep clocks in correspondence with the solar year.

RETURN VALUES
       The strftime() function returns the number of bytes  written  into  the
       array  pointed to by the s parameter when the total number of resulting
       bytes, including the terminating null byte, is not more than the	 value
       of the maxsize parameter.  The returned value does not count the termi‐
       nating null byte in the number of bytes written into the array.	Other‐
       wise,  a	 value of 0 cast to size_t is returned and the contents of the
       array are undefined.

RELATED INFORMATION
       Functions: ctime(3), mbstowcs(3), setlocale(3), strptime(3)

       delim off

								   strftime(3)
[top]

List of man pages available for DigitalUNIX

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net