Branch: Tag:

2018-01-31

2018-01-31 19:13:26 by Stephen R. van den Berg <srb@cuci.nl>

strptime/strftime: Added at global level; rip out special strptime/strftime in Val.*.

109:   #ifdef HAVE_STRPTIME    /*! @decl int(0..1) strptime( string(1..255) format, string(1..255) data )    *! -  *! Parse the given @[data] using the format in @[format] as a date. +  *! @note +  *! The @expr{format@} and @expr{data@} are reversed.    *! -  *! @dl -  *! @item %% -  *! The % character. -  *! -  *! @item %a or %A -  *! The weekday name according to the C locale, in abbreviated -  *! form or the full name. -  *! -  *! @item %b or %B or %h -  *! The month name according to the C locale, in abbreviated form -  *! or the full name. -  *! -  *! @item %c -  *! The date and time representation for the C locale. -  *! -  *! @item %C -  *! The century number (0-99). -  *! -  *! @item %d or %e -  *! The day of month (1-31). -  *! -  *! @item %D -  *! Equivalent to %m/%d/%y. -  *! -  *! @item %H -  *! The hour (0-23). -  *! -  *! @item %I -  *! The hour on a 12-hour clock (1-12). -  *! -  *! @item %j -  *! The day number in the year (1-366). -  *! -  *! @item %m -  *! The month number (1-12). -  *! -  *! @item %M -  *! The minute (0-59). -  *! -  *! @item %n -  *! Arbitrary whitespace. -  *! -  *! @item %p -  *! The C locale's equivalent of AM or PM. -  *! -  *! @item %R -  *! Equivalent to %H:%M. -  *! -  *! @item %S -  *! The second (0-60; 60 may occur for leap seconds; -  *! earlier also 61 was allowed). -  *! -  *! @item %t -  *! Arbitrary whitespace. -  *! -  *! @item %T -  *! Equivalent to %H:%M:%S. -  *! -  *! @item %U -  *! The week number with Sunday the first day of the week (0-53). -  *! -  *! @item %w -  *! The weekday number (0-6) with Sunday = 0. -  *! -  *! @item %W -  *! The week number with Monday the first day of the week (0-53). -  *! -  *! @item %x -  *! The date, using the C locale's date format. -  *! -  *! @item %X -  *! The time, using the C locale's time format. -  *! -  *! @item %y -  *! The year within century (0-99). When a century is not -  *! otherwise specified, values in the range 69-99 refer to years -  *! in the twentieth century (1969-1999); values in the range -  *! 00-68 refer to years in the twenty-first century (2000-2068). -  *! -  *! @item %Y -  *! The year, including century (for example, 1991). -  *! @enddl -  *! +  *! @seealso +  *! @[strptime]    */    PIKEFUN int(0..1) strptime( string(1..255) format, string(1..255) data )    {
208:    /*! @decl string(1..255) strftime( string(1..255) format )    *! See also @[Gettext.setlocale]    *! -  *! Convert the structure to a string. -  *! -  *! @dl -  *! @item %a -  *! The abbreviated weekday name according to the current locale -  *! -  *! @item %A -  *! The full weekday name according to the current locale. -  *! -  *! @item %b -  *! The abbreviated month name according to the current locale. -  *! -  *! @item %B -  *! The full month name according to the current locale. -  *! -  *! @item %c -  *! The preferred date and time representation for the current locale. -  *! -  *! @item %C -  *! The century number (year/100) as a 2-digit integer. -  *! -  *! @item %d -  *! The day of the month as a decimal number (range 01 to 31). -  *! -  *! @item %D -  *! Equivalent to @expr{%m/%d/%y@}. (for Americans only. -  *! Americans should note that in other countries @expr{%d/%m/%y@} -  *! is rather common. This means that in international context -  *! this format is ambiguous and should not be used.) -  *! -  *! @item %e -  *! Like @expr{%d@}, the day of the month as a decimal number, -  *! but a leading zero is replaced by a space. -  *! -  *! @item %E -  *! Modifier: use alternative format, see below. -  *! -  *! @item %F -  *! Equivalent to %Y-%m-%d (the ISO 8601 date format). (C99) -  *! -  *! @item %G -  *! The ISO 8601 week-based year (see NOTES) with century as a -  *! decimal number. The 4-digit year corresponding to the ISO -  *! week number (see @expr{%V@}). This has the same format and -  *! value as @expr{%Y@}, except that if the ISO week number -  *! belongs to the previous or next year, that year is used instead. -  *! -  *! @item %g -  *! Like @expr{%G@}, but without century, that is, -  *! with a 2-digit year (00-99). (TZ) -  *! -  *! @item %h -  *! Equivalent to %b. -  *! -  *! @item %H -  *! The hour as a decimal number using a 24-hour clock (range 00 to 23). -  *! -  *! @item %I -  *! The hour as a decimal number using a 12-hour clock (range 01 to 12). -  *! -  *! @item %j -  *! The day of the year as a decimal number (range 001 to 366). -  *! -  *! @item %k -  *! The hour (24-hour clock) as a decimal number (range 0 to 23); -  *! single digits are preceded by a blank. (See also @expr{%H@}.) -  *! -  *! @item %l -  *! The hour (12-hour clock) as a decimal number (range 1 to 12); -  *! single digits are preceded by a blank. (See also @expr{%I@}.) -  *! -  *! @item %m -  *! The month as a decimal number (range 01 to 12). -  *! -  *! @item %M -  *! The minute as a decimal number (range 00 to 59). -  *! -  *! @item %n -  *! A newline character. (SU) -  *! -  *! @item %O -  *! Modifier: use alternative format, see below. (SU) -  *! -  *! @item %p -  *! Either @expr{"AM"@} or @expr{"PM"@} according to the given time -  *! value, or the corresponding strings for the current locale. -  *! Noon is treated as @expr{"PM"@} and midnight as @expr{"AM"@}. -  *! -  *! @item %P -  *! Like @expr{%p@} but in lowercase: @expr{"am"@} or @expr{"pm"@} -  *! or a corresponding string for the current locale. -  *! -  *! @item %r -  *! The time in a.m. or p.m. notation. In the POSIX locale this is -  *! equivalent to @expr{%I:%M:%S %p@}. -  *! -  *! @item %R -  *! The time in 24-hour notation (@expr{%H:%M@}). (SU) -  *! For a version including the seconds, see @expr{%T@} below. -  *! -  *! @item %s -  *! The number of seconds since the Epoch, -  *! 1970-01-01 00:00:00 +0000 (UTC). (TZ) -  *! -  *! @item %S -  *! The second as a decimal number (range 00 to 60). -  *! (The range is up to 60 to allow for occasional leap seconds.) -  *! -  *! @item %t -  *! A tab character. (SU) -  *! -  *! @item %T -  *! The time in 24-hour notation (@expr{%H:%M:%S@}). (SU) -  *! -  *! @item %u -  *! The day of the week as a decimal, range 1 to 7, Monday being 1. -  *! See also @expr{%w@}. (SU) -  *! -  *! @item %U -  *! The week number of the current year as a decimal number, -  *! range 00 to 53, starting with the first Sunday as the first -  *! day of week 01. See also @expr{%V@} and @expr{%W@}. -  *! -  *! @item %V -  *! The ISO 8601 week number of the current year as a decimal number, -  *! range 01 to 53, where week 1 is the first week that has at least -  *! 4 days in the new year. See also @expr{%U@} and @expr{%W@}. -  *! -  *! @item %w -  *! The day of the week as a decimal, range 0 to 6, Sunday being 0. -  *! See also @expr{%u@}. -  *! @enddl +  *! @seealso +  *! @[strftime]    */    PIKEFUN string(1..255) strftime(string(1..255) format)    { -  char *buffer = xalloc( 8192 ); +  char buffer[8192];    buffer[0] = 0; -  strftime_zone( buffer, 8192, format->str, &THIS->t ); -  push_text( buffer ); -  free(buffer); +  strftime_zone(buffer, sizeof(buffer), format->str, &THIS->t); +  push_text(buffer);    }       /*! @decl int(0..60) sec;