views:

43

answers:

2

Does the time always come after the date, with a space in between, in every culture on earth?

i see that Microsoft FCL assumes that it does:

public string get_FullDateTimePattern()
{
    if (this.fullDateTimePattern == null)
    {
        this.fullDateTimePattern = this.LongDatePattern + " " + this.LongTimePattern;
    }
    return this.fullDateTimePattern;
}

Is this an assumption i can make in every development language for every culture?

A: 

I would think this to be a stylistic choice more than anything. For example in English either order is acceptable:

I'll see you on November 4th at 5pm.

or

Your appointment is 10am on January 3rd.

I would think the same could apply for most (if not any) culture. Putting the date before the time tends to follow the "big endian" style of putting the most significant values first.

fbrereto
And how do you, as an english speaker, write your dates and times. i'm sure you would be equally grumpy if Windows defaulted to showing you file times in explorer as `2010-03-12T22:30:01+01:00`, `11:30ᴘᴍ on January 3rd`. And the reason i know you don't like that date format is that you didn't go to your control panel to change it.
Ian Boyd
@Ian: "And how do you, as an english speaker, write your dates and times"? Well, it depends on the context. And the format settings used on my computer do not match my personal formatting style.
fbrereto
@fbrereto Well i'm going to honor your preferences that you've selected for you computer as best as possible. The only thing i can't find a setting for is a string that contains both dates and times. .NET solves the issue by forcing time to always come after date. And i can do that to, if every country reads like that. i would have through RTL cultures have time on the left. If they do, then .NET shows times wrong. If they don't, then .NET is right.
Ian Boyd
If you could shim it in you could also fall back on c++'s iostreams and `std::locale` to do date and time formatting if .NET fails to pass muster.
fbrereto
A: 

I don't know of any specific locales, but: The widely used ISO standard 8601 (often used e.g. in XML files) uses datetimes like "2010-03-12T22:30:01+01:00", so the separator in that case would be T instead of a space.

Chris Lercher
i know of no language that writes dates like that.
Ian Boyd
Well, it's a "machine language". And if you want to have the possibility to not only display dates to users, but also to write these dates into XML files etc, then a method like get_FullDateTimePattern() should IMO be generic enough to allow that (however, I don't know, if that method would _only_ be used to produce datetimes directly to end users).
Chris Lercher
i'm trying to construct a Date+Time string, to display to the user in their selected locale. From Windows i **can** get their preferred **Date** format (`LongDatePattern`), and their preferred **Time** format (LongTimePattern). But Windows provides no `LongDateTimePattern`. i could blindly assume that time should always come before dates (which isn't true in english), or i could assume blindly assume that dates always come before times (which is proper for english speaking Canada - i have no idea about those crazy americans)
Ian Boyd
In that case, I'd do it as you suggest - and give my end users some opportunity to provide feedback to me in some way (bug tracker/forum/...), in case there's actually somebody who wants to display it the other way around (I mean, displaying it wrong will probably not be fatal, or make the datetime unreadable :-)
Chris Lercher