digitalmars.D - Request: std.date should support non-US date formats
- Don Clugston (14/14) Sep 05 2005 Right now, all of the formats in std.date are useless to me.
- MicroWizard (5/19) Sep 05 2005 Agree.
- Victor Nakoryakov (6/12) Sep 06 2005 And russians :)
-
Stewart Gordon
(22/24)
Sep 06 2005
- Carlos Santander (6/26) Sep 07 2005 Regardless of what toString() returns, I still think there should be a
- Regan Heath (39/58) Sep 07 2005 Yes. Like (probably using) strftime, eg.
-
Stewart Gordon
(33/40)
Sep 08 2005
- Regan Heath (20/51) Sep 08 2005 YAMS because I didn't post it. Here is the rest of the doc:
Right now, all of the formats in std.date are useless to me. Where I come from, 9/11 is the 9th of November. But now, I'm in a non-English speaking country, and the names of the months are different. The format which makes the most sense internationally is YYYY-MM-DD hh:mm:ss, and I would recommend there be a function which returns "1996-05-02 02:04:57 GMT-0800". I think this is actually what toString() should return. This is particularly important in view of the proposal for embedded documentation, with an option for specifying "Date:" I'm not sure that this can be done in general without knowing the locale; the allowable formats would need to be restricted (and please don't restrict them to US date formats!). -Don.
Sep 05 2005
Agree. When more choices are available, use the ANSI standard (YYYY.MM.DD) All hungarians will be happy ... like me ;-))) Tamas Nagy In article <dfhro0$221q$1 digitaldaemon.com>, Don Clugston says...Right now, all of the formats in std.date are useless to me. Where I come from, 9/11 is the 9th of November. But now, I'm in a non-English speaking country, and the names of the months are different. The format which makes the most sense internationally is YYYY-MM-DD hh:mm:ss, and I would recommend there be a function which returns "1996-05-02 02:04:57 GMT-0800". I think this is actually what toString() should return. This is particularly important in view of the proposal for embedded documentation, with an option for specifying "Date:" I'm not sure that this can be done in general without knowing the locale; the allowable formats would need to be restricted (and please don't restrict them to US date formats!). -Don.
Sep 05 2005
MicroWizard wrote:Agree. When more choices are available, use the ANSI standard (YYYY.MM.DD) All hungarians will be happy ... like me ;-))) Tamas NagyAnd russians :) -- Victor (aka nail) Nakoryakov nail-mail<at>mail<dot>ru Krasnoznamensk, Moscow, Russia
Sep 06 2005
Don Clugston wrote:Right now, all of the formats in std.date are useless to me. Where I come from, 9/11 is the 9th of November.<snip> Yes, std.date has enough holes and warts to be getting on with. http://www.digitalmars.com/drn-bin/wwwnews?D/27490 http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D.bugs/2365 But see also my utility library http://pr.stewartsplace.org.uk/d/ which has date/time stuff. The DateValue and TimeValue types have toFormatString (currently implemented only for Windows), which generates a date/time string in the OS-defined format. (Must set Doxygen up properly so that it's documented next time!) In a future version I plan to add a format string system to it. http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/6193 Stewart. -- -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCS/M d- s:- C++ a->--- UB P+ L E W++ N+++ o K- w++ O? M V? PS- PE- Y? PGP- t- 5? X? R b DI? D G e++>++++ h-- r-- !y ------END GEEK CODE BLOCK------ My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
Sep 06 2005
Don Clugston escribió:Right now, all of the formats in std.date are useless to me. Where I come from, 9/11 is the 9th of November. But now, I'm in a non-English speaking country, and the names of the months are different. The format which makes the most sense internationally is YYYY-MM-DD hh:mm:ss, and I would recommend there be a function which returns "1996-05-02 02:04:57 GMT-0800". I think this is actually what toString() should return. This is particularly important in view of the proposal for embedded documentation, with an option for specifying "Date:" I'm not sure that this can be done in general without knowing the locale; the allowable formats would need to be restricted (and please don't restrict them to US date formats!). -Don.Regardless of what toString() returns, I still think there should be a formatDate() function that takes a date and a format string (or viceversa) so you can have the date in any format you want. -- Carlos Santander Bernal
Sep 07 2005
On Wed, 07 Sep 2005 18:10:08 -0500, Carlos Santander <csantander619 gmail.com> wrote:Don Clugston escribió:Yes. Like (probably using) strftime, eg. import std.c.time; import std.stdio; void main() { char[] res = new char[100]; time_t now = time(null); res.length = strftime(res.ptr,res.length,"%a %d %b %Y",localtime(&now)); writefln("%s",res); } Regan p.s. FYI... %a Abbreviated weekday name %A Full weekday name %b Abbreviated month name %B Full month name %c Date and time representation appropriate for locale %d Day of month as decimal number (01 - 31) %H Hour in 24-hour format (00 - 23) %I Hour in 12-hour format (01 - 12) %j Day of year as decimal number (001 - 366) %m Month as decimal number (01 - 12) %M Minute as decimal number (00 - 59) %p Current locale's A.M./P.M. indicator for 12-hour clock %S Second as decimal number (00 - 59) %U Week of year as decimal number, with Sunday as first day of week (00 - 53) %w Weekday as decimal number (0 - 6; Sunday is 0) %W Week of year as decimal number, with Monday as first day of week (00 - 53) %x Date representation for current locale %X Time representation for current locale %y Year without century, as decimal number (00 - 99) %Y Year with century, as decimal number %z Time-zone name or abbreviation; no characters if time zone is unknown %Z (as above) %% Percent signRight now, all of the formats in std.date are useless to me. Where I come from, 9/11 is the 9th of November. But now, I'm in a non-English speaking country, and the names of the months are different. The format which makes the most sense internationally is YYYY-MM-DD hh:mm:ss, and I would recommend there be a function which returns "1996-05-02 02:04:57 GMT-0800". I think this is actually what toString() should return. This is particularly important in view of the proposal for embedded documentation, with an option for specifying "Date:" I'm not sure that this can be done in general without knowing the locale; the allowable formats would need to be restricted (and please don't restrict them to US date formats!). -Don.Regardless of what toString() returns, I still think there should be a formatDate() function that takes a date and a format string (or viceversa) so you can have the date in any format you want.
Sep 07 2005
Regan Heath wrote:On Wed, 07 Sep 2005 18:10:08 -0500, Carlos Santander <csantander619 gmail.com> wrote:<snip><snip> UIMS this falls somewhat short of letting you have the date in _any_ format. For example, I don't see any ways of controlling capitalisation or leading zeros. Since I proposed a format for format strings http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/6193 I've been working a bit on a spec, which hopefully I'll share in the near future. But to give an example of how it works, the letter 'm' is defined like this: m month number without leading 0 mm month number with leading 0 mmm abbreviated month name, lowercase Mmm abbreviated month name, initial cap MMM abbreviated month name, uppercase mmmm full month name, lowercase Mmmm full month name, initial cap MMMM full month name, uppercase Things I like about my system: - it seems more natural-looking - it's a little more logical - the letter denotes what is displayed and the length and capitalisation denote how it is displayed - it should be reasonably extensible without breaking the logic Stewart. -- -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCS/M d- s:- C++ a->--- UB P+ L E W++ N+++ o K- w++ O? M V? PS- PE- Y? PGP- t- 5? X? R b DI? D G e++>++++ h-- r-- !y ------END GEEK CODE BLOCK------ My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.Regardless of what toString() returns, I still think there should be a formatDate() function that takes a date and a format string (or viceversa) so you can have the date in any format you want.Yes. Like (probably using) strftime, eg.
Sep 08 2005
On Thu, 08 Sep 2005 10:56:24 +0100, Stewart Gordon <smjg_1998 yahoo.com> wrote:Regan Heath wrote:YAMS because I didn't post it. Here is the rest of the doc: <quote> that case, the meaning of the format code is changed as follows. (%#a, %#A, %#b, %#B, %#p, %#X, %#z, %#Z (%#c) Long date and time representation, appropriate for current locale. For example: “Tuesday, March 14, 1995, 12:41:29â€. (%#x) Long date representation, appropriate to current locale. For example: “Tuesday, March 14, 1995â€. (%#d, %#H, %#I, %#j, %#m, %#M, %#S, %#U, %#w, %#W, %#y, %#Y) Remove leading zeros (if any). </quote>On Wed, 07 Sep 2005 18:10:08 -0500, Carlos Santander <csantander619 gmail.com> wrote:<snip><snip> UIMSRegardless of what toString() returns, I still think there should be a formatDate() function that takes a date and a format string (or viceversa) so you can have the date in any format you want.Yes. Like (probably using) strftime, eg.this falls somewhat short of letting you have the date in _any_ format. For example, I don't see any ways of controlling capitalisation or leading zeros.See above. %#d for example.Since I proposed a format for format strings http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/6193 I've been working a bit on a spec, which hopefully I'll share in the near future. But to give an example of how it works, the letter 'm' is defined like this: m month number without leading 0 mm month number with leading 0 mmm abbreviated month name, lowercase Mmm abbreviated month name, initial cap MMM abbreviated month name, uppercase mmmm full month name, lowercase Mmmm full month name, initial cap MMMM full month name, uppercase Things I like about my system: - it seems more natural-looking - it's a little more logical - the letter denotes what is displayed and the length and capitalisation denote how it is displayed - it should be reasonably extensible without breaking the logicCool. Regan
Sep 08 2005