locale(3f) - [M_time:DATE_PRINTING] allow for selecting languages to represent month and weekday names (LICENSE:MIT)
Synopsis
Description
Options
Example
Author
License
subroutine locale(name,month_names,weekday_names, & & month_names_abbr,weekday_names_abbr,IERR)
character(len=*),intent(in) :: name character(len=*),intent(in),optional :: month_names(12) character(len=*),intent(in),optional :: month_names_abbr(12) character(len=*),intent(in),optional :: weekday_names(7) character(len=*),intent(in),optional :: weekday_names_abbr(7) integer,intent(out) :: ierr
given a pre-defined locale name or strings to substitute for month names and weekday names provide some basic support for non-POSIX labels in date representation.The parameters are default character types and so may be limited to the basic ASCII character set, but are typically limited to the extended ASCII set.
This is only a basic attempt to support internationalization and currently just supports basic substitution of the default POSIX names with the alternate strings. As support for UTF-8 grows among Fortran compilers something more robust will hopefully emerge to provide full internationalization of the date representations.
name predefined name or reserved name "user" month_names 12 month names weekday_names 7 weekday names month_names_abbr 12 month name abbreviations weekday_names_abbr 7 weekday name abbreviations ierr if non-zero an error occurred
The NAME parameter may be a pre-defined name or the special name "user". The current pre-defined names are
’bokmal’,’catalan’,’czech’,’dansk’/’danish’,’deutsch’/’german’,’dutch’, ’eesti’/’estonian’,’english’,’finnish’,’french’,’galego’/’galician’, ’hrvatski’/’croation’,’hungarian’,’icelandic’,’italian’,’korean’, ’lithuanian’,’norwegian’,’nynorsk’,’polish’,’portuguese’,’romanian’, ’slovak’,’slovene’/’slovenian’,’spanish’,’swedish’,’turkish’These non-ISO-8859 character sets are defined in terms of ISO-8859 but will not work on most platforms
’greek’, ’russian’,’thai’, ’hebrew’,’japanese’The remaining reserved names take special actions
o POSIX load POSIX names o LANGUAGE use value of environment variable LANGUAGE o user placeholder indicating to expect at least one of the optional values to be set o reset,ISO-8601 reset back to initial defaults o show print user-defined values to stdout o chars dump characters from chars([(i,i=0,255)])
Sample program:
program demo_locale use M_time, only : locale, now implicit none call locale(’POSIX’) write(*,*)now() call locale(’french’) write(*,*)now() call mine() write(*,*)now() contains subroutine mine() character(len=*),parameter :: months(12)=[ character(len=9) :: & &’JANUARY’,’FEBRUARY’,’MARCH ’,’APRIL ’,’MAY ’,’JUNE ’, & &’JULY ’,’AUGUST ’,’SEPTEMBER’,’OCTOBER’,’NOVEMBER’,’DECEMBER’] character(len=*),parameter :: weekdays(7)=[character(len=9) :: & &’MONDAY’,’TUESDAY’,’WEDNESDAY’,’THURSDAY’,’FRIDAY’,’SATURDAY’,’SUNDAY’] character(len=3),parameter :: short_months(12)=months(:)(1:3) character(len=3),parameter :: short_weekdays(7)=weekdays(:)(1:3) integer :: ierr call locale(’user’,months,short_months,weekdays,short_weekdays,ierr) end subroutine mine end program demo_localeResults:
Sunday, September 29th, 2024 7:55:00 PM UTC-04:00 dimanche, septembre 29th, 2024 7:55:00 PM UTC-04:00 JUL, SEPTEMBER 29th, 2024 7:55:00 PM UTC-04:00
John S. Urban, 2015
Nemo Release 3.1 | locale (3) | February 23, 2025 |