-
-
Notifications
You must be signed in to change notification settings - Fork 102
Consider formatting times with a T
rather than a space between date and time
#213
Comments
The specific issue is when you have a collection, e.g. |
T is also part of the iso formatted output FWIW |
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:
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. |
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 |
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? |
We never really garnered a consensus, we could close for now pending further discussion, I'd like some more community input really. |
I am ok with this :) |
Quoting @dchelimsky from rspec/rspec.github.io#70:
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). AlsoTime#inspect
does not have theT
. 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.The text was updated successfully, but these errors were encountered: