Re:YAML: probably not so great after all (2017)
by emodendroket on Wednesday June 20, 2018 @04:31PM
(#17359479)
If you're going to do this kind of thing why would you not add a standard date format
[ Parent
| on HN ]
Re:YAML: probably not so great after all (2017)
by continuational on Thursday June 21, 2018 @05:44AM
(#17363498)
Just use a string and ISO 8601? “2018-03-25”
Re:YAML: probably not so great after all (2017)
by emodendroket on Thursday June 21, 2018 @09:40AM
(#17364957)
Wow, I can "just" use that, thanks. The problem is that JSON is an interchange format, meaning that I need to implement this serialization and deserialization quirk on every producer/consumer of my API (which, you know, avoiding is kind of the point of using a standard interchange format). Furthermore, because everything is a string, I can't unambiguously indicate something is meant to be a string in that format rather than a date.
Re:YAML: probably not so great after all (2017)
by wildrhythms on Thursday June 21, 2018 @08:19AM
(#17364402)
What's the timezone?
Re:YAML: probably not so great after all (2017)
by lysium on Thursday June 21, 2018 @04:51PM
(#17369181)
Do you need a time zone for dates?
Re:YAML: probably not so great after all (2017)
by wildrhythms on Thursday June 21, 2018 @08:52PM
(#17370410)
Consider if I'm storing a user's (local) birthday on my server:
{..., "birthday": "2018-03-25"}
If my server is located in New York City, and the user is in Sydney, then my server isn't going to wish them happy birthday in time.So maybe we could do:
{..., "birthday": "2018-03-25", "location": "Sydney/AU"}
But at this point we might as well use a standardized time format (UTC) with a timezone offset. Maybe I'm thinking too far into it?
Re:YAML: probably not so great after all (2017)
by webXL on Friday June 22, 2018 @08:43AM
(#17373495)
ISO 8601 has you covered:
Year:
YYYY (eg 1997)
Year and month:
YYYY-MM (eg 1997-07)
Complete date:
YYYY-MM-DD (eg 1997-07-16)
Complete date plus hours and minutes:
YYYY-MM-DDThh:mmTZD (eg 1997-07-16T19:20+01:00)
Complete date plus hours, minutes and seconds:
YYYY-MM-DDThh:mm:ssTZD (eg 1997-07-16T19:20:30+01:00)
Complete date plus hours, minutes, seconds and a decimal fraction of a second
YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00)
where:
YYYY = four-digit year
MM = two-digit month (01=January, etc.)
DD = two-digit day of month (01 through 31)
hh = two digits of hour (00 through 23) (am/pm NOT allowed)
mm = two digits of minute (00 through 59)
ss = two digits of second (00 through 59)
s = one or more digits representing a decimal fraction of a second
TZD = time zone designator (Z or +hh:mm or -hh:mm)