Email or username:

Password:

Forgot your password?
Niki Tonsky

Okay Twitter, what type of date format is that???

22 comments
L3viathan

@nikitonsky maybe they initially thought Twitter wouldn't last a year and added this later?

Christian Tietze

@nikitonsky Bespoke multi-layered regex is my guess :)

(\s\d{4}) → year
(+\d{4}) → time zone

eaaaasy 😎

...

wait, what international standards?

Niki Tonsky

@ctietze I mean, I get RFC 822, but it’s 'Tue, 3 Jun 2008 11:05:30 GMT'

Why would you put year _after_ time zone???

Григорий Клюшников

(btw Mastodon API and ActivityPub also use strings for timestamps)

Niki Tonsky

@grishka I don’t mind the string (what else would you use?) but the format itself. It resembles RFC 822, but year is for some reason _after_ time zone

Григорий Клюшников

Niki, unixtime, of course. A string can be malformed. A number can not, not without making the entire JSON invalid.

iliazeus

@grishka ...but do you mean _true_ unixtime (i.e. in seconds), or Java/JavaScript "unixtime" (i.e. in milliseconds)?

@nikitonsky

Григорий Клюшников

iliazeus, in most cases, true unixtime as a 64-bit integer. You usually don't need millisecond precision.

iliazeus

@grishka so you're going against default conventions both in JVM (new Date(ms) and date.getTime()) and in JS (new Date(ms) and date.valueOf())? (possibly somewhere else, idk)

What I'm saying is, if picking a number-based timestamp format, I'd pick unixtime in milliseconds. I thing it would be the least surprising option.

@nikitonsky

Григорий Клюшников

iliazeus, at least PHP's time() returns unixtime in seconds so there are examples of both.

iliazeus

@grishka well, PHP's stdlib was basically starting as thin wrappers over C stdlib functions.

Python also has it in seconds, but it does this weird thing where its timestamps are floating-point.

C# seems to use 100-microsecond "ticks".

Go uses nanoseconds, iirc.

So yeah, it's even more ambiguous.

If I have a choice, I usually prefer ISO 8601 strings myself. They're standard, unambiguous, human-readable, and even sortable as strings.

@nikitonsky

Григорий Клюшников

iliazeus, iirc it's also popular in binary file formats to store timestamps as unixtime in seconds.

Niki Tonsky

@grishka why would string be malformed but number wouldn’t?

Sergey Sign

@nikitonsky yes, my bad(

> This method is similar to the strftime() function defined in ISO C and POSIX.

Sergey Sign

@nikitonsky
oops
'%+' is '%a %b %e %H:%M:%S %Z %Y'
but you have '%a %b %e %H:%M:%S %z %Y'

Sergey Sign

@nikitonsky I remembered a story about this format : )

stackoverflow.com/questions/25

> There is a package time format constant named RubyDate; it's a misnomer.

The Go authors were misled by Go Issue 518 which claimed that Ruby Time.now outputs Tue Jan 12 02:52:59 -0800 2010

Later, the issue was revised to say that Tue Jan 12 02:52:59 -0800 2010 was the date format used by the Twitter API. In the beginning, in the "Fail Whale" days, Twitter used Ruby-on-Rails, which may be why they assumed it was a Ruby date format.

@nikitonsky I remembered a story about this format : )

stackoverflow.com/questions/25

> There is a package time format constant named RubyDate; it's a misnomer.

The Go authors were misled by Go Issue 518 which claimed that Ruby Time.now outputs Tue Jan 12 02:52:59 -0800 2010

dmitriid

@nikitonsky

Lol. They broke it again. It used to be non-RFC despite the docs a few years ago. Then they fixed it. And now theybroke it again. I can't even imagine *how* you can end up with this format

Go Up