Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Consider formatting times with a T rather than a space between date and time #213

Closed
myronmarston opened this issue Jun 12, 2015 · 7 comments

Comments

@myronmarston
Copy link
Member

Quoting @dchelimsky from rspec/rspec.github.io#70:

I think it would be easier to read the time format if it had no spaces in it e.g. 2015-06-09T07:49:16.610635000-0700 rather than 2015-06-09 07:49:16.610635000 -0700. It's not obvious in the examples in the post, which all line up very nicely, but it would be more obvious in a collection of times.

I'm on the fence here. It's not obvious to me how the T makes it read easier (in fact, I lean towards it making it harder to read -- the space provides a visual separation between date and time, whereas with the T it runs together). Also Time#inspect does not have the T. Our custom time formatting just prints the seconds as a full float rather than as an integer. The rest of the time formatting is the same as ruby's built-in time formatting, which seems like a good way to go, or at least a good way to start.

Regardless, if there's community consensus around the T being an improvement I'd be happy to see it changed.

@dchelimsky
Copy link

The specific issue is when you have a collection, e.g. [2015-06-09 07:49:16.610635000 -0700, 2015-06-09 07:49:16.610635000 -0700, 2015-06-09 07:49:16.610635000 -0700, 2015-06-09 07:49:16.610635000 -0700]. There are actually two spaces in each timestamp - the one between date and time and the one between time and offset, which btw, should include the colon e.g. 2015-06-09T07:49:16.610635000-07:00. A bunch of those in a row are easier to parse (for me): [2015-06-09T07:49:16.610635000-07:00, 2015-06-09T07:49:16.610635000-07:00, 2015-06-09T07:49:16.610635000-07:00, 2015-06-09T07:49:16.610635000-07:00]

@JonRowe
Copy link
Member

JonRowe commented Jun 12, 2015

T is also part of the iso formatted output FWIW

@cupakromer
Copy link
Member

I'm on the fence a bit about this one. Here's output with different "default" formatting as provided in Ruby (and Rails):

t1 = Time.zone.now
# => Sat, 13 Jun 2015 15:45:05 EST -05:00

t1.inspect
# => "Sat, 13 Jun 2015 15:45:05 EST -05:00"

t1.to_s
# => "2015-06-13 15:45:05 -0500"

t1.as_json
# => "2015-06-13T15:45:05.603-05:00"

Of course I'm using the US locale too.

Looking at an individual time I personally find "2015-06-13 15:45:05.603635000-0500" to be optimal for my visual consumption. But that's non-standard compared to the usual representations.

Let's compare lists of times side-by-side:

  • [2015-06-09T07:49:16.610635000-07:00, 2015-06-09T07:49:16.610635000-07:00, 2015-06-09T07:49:16.610635000-07:00, 2015-06-09T07:49:16.610635000-07:00]
  • [2015-06-09 07:49:16.610635000 -07:00, 2015-06-09 07:49:16.610635000 -07:00, 2015-06-09 07:49:16.610635000 -07:00, 2015-06-09 07:49:16.610635000 -07:00]
  • [2015-06-09 07:49:16.610635000-07:00, 2015-06-09 07:49:16.610635000-07:00, 2015-06-09 07:49:16.610635000-07:00, 2015-06-09 07:49:16.610635000-07:00]
  • [2015-06-09_07:49:16.610635000-07:00, 2015-06-09_07:49:16.610635000-07:00, 2015-06-09_07:49:16.610635000-07:00, 2015-06-09_07:49:16.610635000-07:00]
  • [2015-06-09@07:49:16.610635000-07:00, 2015-06-09@07:49:16.610635000-07:00, 2015-06-09@07:49:16.610635000-07:00, 2015-06-09@07:49:16.610635000-07:00]
  • [2015-06-09.07:49:16.610635000-07:00, 2015-06-09.07:49:16.610635000-07:00, 2015-06-09.07:49:16.610635000-07:00, 2015-06-09.07:49:16.610635000-07:00]
  • [2015-06-09::07:49:16.610635000-07:00, 2015-06-09::07:49:16.610635000-07:00, 2015-06-09::07:49:16.610635000-07:00, 2015-06-09::07:49:16.610635000-07:00]

I do find that the 'T' makes the date blend too much into the string making it difficult for me to parse the date from time. Though I do agree with David that spaces make it harder to parse the repeated list of items. My brain often uses the space as the first rapid visual indication for the list separation, and only if I get confused does my brain backup and take the slower route of identifying and parsing the tiny comma.

Looking at all of the above, I find, in a list that using the underscore "" is easiest for me. My brain is able to easily parse the separation between the date and time, however, the underscore allows my brain to also quickly identify that it's not a list separator. I'm guessing this is from constantly using "" underscores in ruby variables names.

@JonRowe
Copy link
Member

JonRowe commented Jun 15, 2015

The current formatting is the default Ruby formating @cupakromer, your examples are with active supports extensions I believe. I'm ok leaving it as it is but I do think if we should change it we should use the iso 8601 format (which happens to be the same as Rails provides with to_json but thats not where it's from)

@benoittgt
Copy link
Member

I am in favor of using iso 8601 but is it still something we would like to change?

Otherwise maybe we can close this discussion?

@JonRowe
Copy link
Member

JonRowe commented Jun 13, 2019

We never really garnered a consensus, we could close for now pending further discussion, I'd like some more community input really.

@benoittgt
Copy link
Member

I am ok with this :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants