Loading ...
Sorry, an error occurred while loading the content.
 

Re: [PBML] Re: Increasing gmtime (long) - localisation

Expand Messages
  • Charles K. Clarkson
    ... According to perllocale: Output produced by POSIX::strftime(), which builds a formatted human-readable date/time string, is affected by the current LC_TIME
    Message 1 of 3 , Apr 25 3:20 PM
      Damien Carbery <daymobrew@...> asked:
      : As a localisation freak (I bug [excuse pun] the developers at work to
      : fix their hard coded strings bugs), I wonder is there a way to get the
      : localised names for the days of the week and the month?

      According to perllocale:

      Output produced by POSIX::strftime(), which builds a formatted
      human-readable date/time string, is affected by the current
      LC_TIME locale. Thus, in a French locale, the output produced
      by the %B format element (full month name) for the first month
      of the year would be ``janvier''. Here's how to get a list of long
      month names in the current locale:


      use POSIX qw(strftime);

      for (0..11) {

      $long_month_name[$_] =

      strftime("%B", 0, 0, 0, 1, $_, 96);

      }

      Note: use locale isn't needed in this example: as a function that
      exists only to generate locale-dependent results, strftime()
      always obeys the current LC_TIME locale.

      And according to POSIX:

      strftime

      Convert date and time information to string. Returns the string.
      Synopsis:


      strftime(fmt, sec, min, hour, mday, mon, year, wday = -1, yday = -1, isdst
      = -1)

      And according to ANSI C:
      <http://www.introl.com/introl-demo/Libraries/C/ANSI_C/time/strftime.html>

      format can be:

      Each conversion specification is replaced by the characters as follows
      which are then copied into the buffer.

      %A
      is replaced by the locale's full weekday name.
      %a
      is replaced by the locale's abbreviated weekday name.
      %B
      is replaced by the locale's full month name.
      %b
      is replaced by the locale's abbreviated month name.
      %c
      is replaced by the locale's appropriate date and time representation.
      %d
      is replaced by the day of the month as a decimal number (01-31).
      %H
      is replaced by the hour (24-hour clock) as a decimal number (00-23).
      %I
      is replaced by the hour (12-hour clock) as a decimal number (01-12).
      %j
      is replaced by the day of the year as a decimal number (001-366).
      %M
      is replaced by the minute as a decimal number (00-59).
      %m
      is replaced by the month as a decimal number (01-12).
      %p
      is replaced by the locale's equivalent of either ``AM'' or ``PM''.
      %S
      is replaced by the second as a decimal number (00-60).
      %U
      is replaced by the week number of the year
      (Sunday as the first day of the week) as a decimal number (00-53).
      %W
      is replaced by the week number of the year
      (Monday as the first day of the week) as a decimal number (00-53).
      %w
      is replaced by the weekday
      (Sunday as the first day of the week) as a decimal number (0-6).
      %X
      is replaced by the locale's appropriate time representation.
      %x
      is replaced by the locale's appropriate date representation.
      %Y
      is replaced by the year with century as a decimal number.
      %y
      is replaced by the year without century as a decimal number (00-99).
      %Z
      is replaced by the time zone name.
      %%
      is replaced by `%'.

      HTH,
      Charles K. Clarkson

      What? - No, no, no, Silly!
      *Perl* is platform independent
      - not it's documentation!
    Your message has been successfully submitted and would be delivered to recipients shortly.