LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-25-2023, 03:00 AM   #1
lvm_
Member
 
Registered: Jul 2020
Posts: 983

Rep: Reputation: 348Reputation: 348Reputation: 348Reputation: 348
date nanoseconds separator


Why does it use comma as decimal point?

Code:
$ date -Ins
2023-10-25T10:50:21,212579800+03:00
$ locale
LANG=C.UTF-8
LANGUAGE=
LC_CTYPE="C.UTF-8"
LC_NUMERIC="C.UTF-8"
LC_TIME="C.UTF-8"
LC_COLLATE="C.UTF-8"
LC_MONETARY="C.UTF-8"
LC_MESSAGES="C.UTF-8"
LC_PAPER="C.UTF-8"
LC_NAME="C.UTF-8"
LC_ADDRESS="C.UTF-8"
LC_TELEPHONE="C.UTF-8"
LC_MEASUREMENT="C.UTF-8"
LC_IDENTIFICATION="C.UTF-8"
LC_ALL=
 
Old 10-25-2023, 07:40 AM   #2
boughtonp
Senior Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 3,627

Rep: Reputation: 2556Reputation: 2556Reputation: 2556Reputation: 2556Reputation: 2556Reputation: 2556Reputation: 2556Reputation: 2556Reputation: 2556Reputation: 2556Reputation: 2556

Because "-I" tells it to use ISO-8601 format, and according to Wikipedia ISO-8601 section 4.2.2.4 states:
Quote:
Originally Posted by ISO 8601:2004(E), ISO, 2004-12-01, 4.2.2.4
... the decimal fraction shall be divided from the integer part by the decimal sign specified in ISO 31-0, i.e. the comma [,] or full stop [.]. Of these, the comma is the preferred sign.
Looks like the author(s) of the date command decided to go with the "preferred sign" rather than take locale into account (which the standard allows). It's also disappointing they didn't bother to document that they had done so.

The actual ISO-8601 standard is frustratingly behind a paywall, but RFC 3339 is a subset which isn't - and it explicitly only goes with decimal point:
Quote:
Originally Posted by RFC 3339 section 5.6
date-fullyear = 4DIGIT
date-month = 2DIGIT ; 01-12
date-mday = 2DIGIT ; 01-28, 01-29, 01-30, 01-31 based on
; month/year
time-hour = 2DIGIT ; 00-23
time-minute = 2DIGIT ; 00-59
time-second = 2DIGIT ; 00-58, 00-59, 00-60 based on leap second
; rules
time-secfrac = "." 1*DIGIT
time-numoffset = ("+" / "-") time-hour ":" time-minute
time-offset = "Z" / time-numoffset

partial-time = time-hour ":" time-minute ":" time-second
[time-secfrac]
full-date = date-fullyear "-" date-month "-" date-mday
full-time = partial-time time-offset

date-time = full-date "T" full-time
However, the date command's implementation of RFC 3339 is incorrect - because whilst "date --rfc-3339=ns" does indeed give a decimal point, it neglects to output the T (which is a useful indicator of a standards-compliant date value), so to get the desired format one must manually construct it: "date '+%FT%T.%N%:z'"


Last edited by boughtonp; 10-25-2023 at 07:42 AM.
 
2 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Changing date separator format paxolin Linux Mint 29 01-07-2017 09:40 AM
[SOLVED] nanoseconds Skaperen Linux - General 5 08-01-2015 08:01 AM
How to get nanoseconds inside the kernel? rainman1985_2010 Programming 2 07-15-2015 09:04 PM
awk: awking the right separator with slashes, colons, commas (date time and data) ezekieldas Linux - Newbie 3 01-04-2011 12:58 PM
Bash command separator/arguments separator reverse Programming 11 12-02-2007 09:21 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:35 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration