News for hackers. Stuff that matters.
Re:Most RESTful APIs Aren't RESTful by majkinetor on Wednesday July 09, 2025 @01:16PM (#44512566)
Amen. Particularly ISO8601.
Re:Most RESTful APIs Aren't RESTful by yndoendo on Wednesday July 09, 2025 @01:28PM (#44512710)
Always thought that a standard like ISO8601 which always stores the date and time in UTC but appends the local time zone would beneficial.
Re:Most RESTful APIs Aren't RESTful by theamk on Wednesday July 09, 2025 @04:58PM (#44514681)
I don't think I ever needed something like that... Since most cases don't need local time zone, why not keep two separate fields?
Re:Most RESTful APIs Aren't RESTful by Jenk on Thursday July 10, 2025 @04:53AM (#44518823)
It's a delimited string. There are many fields within that string already.

    "2025-07-10T09:48:27+01:00" 
That contains, by my quick glance, at least 8 fields of information. I would argue the one field it does not carry but probably should is the _name_ of the timezone it is for.
Re:Most RESTful APIs Aren't RESTful by tbrownaw on Wednesday July 09, 2025 @07:34PM (#44515798)
Sometimes you need your timestamps to be in a named timezone. If I have a meeting at 9am local time next month, I probably want it to still be at 9am even if the government suddenly decided to cancel daylight time.
Re:Most RESTful APIs Aren't RESTful by jcelerier on Wednesday July 09, 2025 @07:52PM (#44515897)
unless the customer you're meeting is in another timezone where the government didn't cancel daylight time
Re:Most RESTful APIs Aren't RESTful by Jenk on Thursday July 10, 2025 @04:44AM (#44518765)
Exchange/GMail/etc. already has this problem/feature. Their response is simple: Follow the organiser's timezone. If it's 9am on the organiser's calendar, it will stay at 9am on the organiser's calendar. Everyone else's appointment will float to match the organiser.
Re:Most RESTful APIs Aren't RESTful by PaulHoule on Thursday July 10, 2025 @08:37PM (#44527275)
There are a few things you want about dates. 1932-04-12 sorts lexically, 04/12/1932 doesn't. So long as you don't use a timezone or always use the same timezone (especially Z) you get this nice property with ISO 8601 which makes it better than the alternatives. Once you include timezones you get into all sorts of problems such as dates (as opposed to date times) only having a partial ordering as the day here in New York starts an hour earlier than Chicago. In an extreme case the Pearl Harbor attack was launched the day after it was executed.

At some point you need real time aware libraries and whatever language you use they've been through several iterations of them (Javascript Date, moment, dayjs, ...) because they got it wrong the first time and probably the second time to.

With ISO 8601 it is easy to get the yyyy, yyyy-mm, hh and other things you might work with primitive tools (awk). Getting the day of the week or the time involved is not hard which gets you to the chronological rosetta stone

https://en.wikipedia.org/wiki/Julian_day

which is a multiplier and and offset away from Unixtime except for all those leap seconds and whatnot. With Unix timestamps comparison is easy and differences are easy and even knowing it is Thorsday is easy; they don't sort as strings but GNU sort has a -n option, only trouble is it is a bunch of twisty little numbers that look alike.

Re:Most RESTful APIs Aren't RESTful by Xenoamorphous on Wednesday July 09, 2025 @03:31PM (#44513933)
That would be solved if JSON had a native date type in ISO format.
Re:Most RESTful APIs Aren't RESTful by SJC_Hacker on Wednesday July 09, 2025 @05:28PM (#44514900)
JSON doesn’t really have data types beyond very simple ones
Re:Most RESTful APIs Aren't RESTful by motorest on Thursday July 10, 2025 @01:13AM (#44517481)
> JSON doesn’t really have data types beyond very simple ones

What do you think primitive types are supposed to be?

Re:Most RESTful APIs Aren't RESTful by Jenk on Thursday July 10, 2025 @04:54AM (#44518840)
The below type definition (TS) fits the ECMA schema for JSON:

    type JSON = 
      string |
      number |
      boolean |
      null |
      JSON[] |
      {[name: string]: JSON}
Re:Most RESTful APIs Aren't RESTful by motorest on Thursday July 10, 2025 @06:56AM (#44519577)
You didn't answered my question.
Re:Most RESTful APIs Aren't RESTful by Jenk on Thursday July 10, 2025 @06:53PM (#44526604)
I'm not the person you asked.
Re:Most RESTful APIs Aren't RESTful by SJC_Hacker on Friday July 11, 2025 @10:24AM (#44532503)
I guess my point was something like an ISO 8601 date would be beyond the scope of a built in data type given JSONs philosophy of a minimal spec. It’s up to the end user to define types like that.
Re:Most RESTful APIs Aren't RESTful by auszeph on Wednesday July 09, 2025 @06:33PM (#44515387)
ISO8601 is really broad with loads of edge cases and differing versions. RFC 3339 is closer, but still with a few quirks. Not sure why we can't have one of these that actually has just one way of representing each instant.

Related: https://ijmacd.github.io/rfc3339-iso8601/

Re:Most RESTful APIs Aren't RESTful by PaulHoule on Thursday July 10, 2025 @08:39PM (#44527293)
I love how that's live!

Since ISO 8601 costs 133 CHF I suspect hardly anybody has actually read it, I think if you wanted something that supports all the weird stuff you might find somebody wrote it in 390 assembly.