Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Locale with ISO 8601 (RFC 3339) date/time format
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
friesia
Apprentice
Apprentice


Joined: 23 Mar 2007
Posts: 202

PostPosted: Fri Apr 05, 2013 11:06 am    Post subject: Locale with ISO 8601 (RFC 3339) date/time format Reply with quote

Is there any system locale with date/time format set to ISO 8601 standard?
I'd like to set LC_TIME variable to that locale.
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6227
Location: Room 101

PostPosted: Fri Apr 05, 2013 10:42 pm    Post subject: Reply with quote

friesia ...

I think we discussed this on irc ... anyhow, I probably wasn't as clear as I could be, basically it isn't the locale as such but the d_fmt, date_fmt, etc, supplied by that locale, and iso-8601 isn't a locale but an output method for strftime.

Code:
# LC_TIME="en_GB.UTF-8" locale -k LC_TIME
abday="Sun;Mon;Tue;Wed;Thu;Fri;Sat"
day="Sunday;Monday;Tuesday;Wednesday;Thursday;Friday;Saturday"
abmon="Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec"
mon="January;February;March;April;May;June;July;August;September;October;November;December"
am_pm=";"
d_t_fmt="%a %d %b %Y %T %Z"
d_fmt="%d/%m/%y"
t_fmt="%T"
t_fmt_ampm=""
era=
era_year=""
era_d_fmt=""
alt_digits=
era_d_t_fmt=""
era_t_fmt=""
time-era-num-entries=0
time-era-entries="S"
week-ndays=7
week-1stday=19971130
week-1stweek=4
first_weekday=2
first_workday=2
cal_direction=1
timezone=""
date_fmt="%a %b %e %H:%M:%S %Z %Y"
time-codeset="UTF-8"

We can see from the above that the date_fmt is "%a %b %e %H:%M:%S %Z %Y", as we can see from the following:

Code:
# LC_TIME="en_GB.UTF-8" date
Fri Apr  5 23:51:24 CEST 2013
# LC_TIME="en_GB.UTF-8" date --iso-8601
2013-04-05
# LC_TIME="en_GB.UTF-8" date "+%F %H:%M:%S"
2013-04-05 23:51:29
# TIME_STYLE="iso-long" date
Fri Apr  5 23:51:36 CEST 2013
# TIME_STYLE="locale" ls -l
total 8
-rw------- 1 khayyam users  2 Mar 28 03:51 foo.txt
-rw------- 1 khayyam users  2 Mar 28 03:51 bar.txt
drwx------ 4 khayyam users 92 Apr  3 06:22 baz
# TIME_STYLE="iso-long" ls -l
total 8
-rw------- 1 khayyam users  2 2013-03-28 03:51 foo.txt
-rw------- 1 khayyam users  2 2013-03-28 03:51 bar.txt
drwx------ 4 khayyam users 92 2013-04-03 06:22 baz

We can see from the above that the date output is modified by strftime.

The en_DK locale uses d_fmt and t_fmt of iso-8601 but this won't effect the output of commands (like 'ls' and 'date') using a specific strftime, or using the date_fmt provided with that locale.

Code:
# LC_TIME="en_DK.UTF-8" locale -k LC_TIME
abday="Sun;Mon;Tue;Wed;Thu;Fri;Sat"
day="Sunday;Monday;Tuesday;Wednesday;Thursday;Friday;Saturday"
abmon="Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec"
mon="January;February;March;April;May;June;July;August;September;October;November;December"
am_pm=";"
d_t_fmt="%Y-%m-%dT%T %Z"
d_fmt="%Y-%m-%d"
t_fmt="%T"
t_fmt_ampm=""
era=
era_year=""
era_d_fmt=""
alt_digits=
era_d_t_fmt=""
era_t_fmt=""
time-era-num-entries=0
time-era-entries="S"
week-ndays=7
week-1stday=19971130
week-1stweek=4
first_weekday=2
first_workday=2
cal_direction=1
timezone=""
date_fmt="%a %b %e %H:%M:%S %Z %Y"
time-codeset="UTF-8"
# LC_TIME="en_DK.UTF-8" date
Sat Apr  6 23:52:20 CEST 2013

So, I'm not sure how this can be achived other than changing the date_fmt set in the specific locale, as I don't think there is a locale who's d_fmt, t_fmt, and date_fmt, are entirely iso-8601. Also, I'm not enirely sure what commands will respect this and provide iso-8601 strftime without other variables being set.

Your may have to do something like this.

HTH & best ... khay
Back to top
View user's profile Send private message
friesia
Apprentice
Apprentice


Joined: 23 Mar 2007
Posts: 202

PostPosted: Sat Apr 06, 2013 4:17 pm    Post subject: Reply with quote

Ok, I guess i"ll use ja_JP instead of making a custom file, it has big-endian representation at least :)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum