digitalmars.D.bugs - d_time and writefln
- Carlos Santander (16/16) May 08 2006 d_time should be recognized by writefln.
- Chris Nicholson-Sauls (6/25) May 08 2006 The problem is, that 'd_time' is just an alias of long, so writef*() jus...
- Stewart Gordon (13/18) May 09 2006 If we have this, then we ought to have a way for the programmer to
- Carlos Santander (10/23) May 09 2006 Another solution would be to add a bit of type information to aliases. I...
- Regan Heath (7/21) May 09 2006 It should remain possible to print the numeric representation. For use i...
- Stewart Gordon (17/22) May 10 2006 There are many different formats for converting dates/times into
d_time should be recognized by writefln. //------------- import std.date; import std.stdio; void main() { d_time fecha = getUTCtime(); writefln("%s",toDateString(fecha)); writefln(fecha); } //------------- Outputs (any system): $ ./test Tue May 09 2006 1147138947602 -- Carlos Santander Bernal
May 08 2006
Carlos Santander wrote:d_time should be recognized by writefln. //------------- import std.date; import std.stdio; void main() { d_time fecha = getUTCtime(); writefln("%s",toDateString(fecha)); writefln(fecha); } //------------- Outputs (any system): $ ./test Tue May 09 2006 1147138947602The problem is, that 'd_time' is just an alias of long, so writef*() just sees it as a long. Maybe d_time could be typedef'd to change this, but would that break anything? If it has no or few cons against it, I'm cool with typedef'ing it, although it would couple std.format and std.date to each other a little. -- Chris Nicholson-Sauls
May 08 2006
Chris Nicholson-Sauls wrote: <snip>The problem is, that 'd_time' is just an alias of long, so writef*() just sees it as a long. Maybe d_time could be typedef'd to change this, but would that break anything? If it has no or few cons against it, I'm cool with typedef'ing it, although it would couple std.format and std.date to each other a little.If we have this, then we ought to have a way for the programmer to define a custom formatting for any typedef. 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.
May 09 2006
Stewart Gordon escribió:Chris Nicholson-Sauls wrote: <snip>Another solution would be to add a bit of type information to aliases. In any case, if d_time is the official way to deal with dates and times in D, I wouldn't be surprised if many people new to D tried to do writefln(getUTCtime()); So, regardless of the solution, I believe printing the numeric representation is wrong.The problem is, that 'd_time' is just an alias of long, so writef*() just sees it as a long. Maybe d_time could be typedef'd to change this, but would that break anything? If it has no or few cons against it, I'm cool with typedef'ing it, although it would couple std.format and std.date to each other a little.If we have this, then we ought to have a way for the programmer to define a custom formatting for any typedef.There should be a way to do this, too.Stewart.-- Carlos Santander Bernal
May 09 2006
On Tue, 09 May 2006 09:47:59 -0500, Carlos Santander <csantander619 gmail.com> wrote:Stewart Gordon escribió:It should remain possible to print the numeric representation. For use in files/records/etc on disk or otherwise. I use the numeric time_t value from time() in C/C++ all the time. It's far easier to read/write a number than parse a string which could be in many different formats. ReganChris Nicholson-Sauls wrote: <snip>Another solution would be to add a bit of type information to aliases. In any case, if d_time is the official way to deal with dates and times in D, I wouldn't be surprised if many people new to D tried to do writefln(getUTCtime()); So, regardless of the solution, I believe printing the numeric representation is wrong.The problem is, that 'd_time' is just an alias of long, so writef*() just sees it as a long. Maybe d_time could be typedef'd to change this, but would that break anything? If it has no or few cons against it, I'm cool with typedef'ing it, although it would couple std.format and std.date to each other a little.
May 09 2006
Regan Heath wrote: <snip>It should remain possible to print the numeric representation. For use in files/records/etc on disk or otherwise. I use the numeric time_t value from time() in C/C++ all the time.There are many different formats for converting dates/times into numbers. Is the format of time_t standardised?It's far easier to read/write a number than parse a string which could be in many different formats.And somewhere between the two is parsing a string that can be in only one format. Depending on whether you want the files your program works with to be human-readable, you could use either a simple numeric representation or a uniform textual notation (ideally the ISO notation). 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.
May 10 2006