Thread overview | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
November 04, 2011 Formatted date | ||||
---|---|---|---|---|
| ||||
Hello. Is there any way how to format date with formating strings? Something like strftime in python; http://docs.python.org/library/datetime.html#strftime-and-strptime-behavior |
November 04, 2011 Re: Formatted date | ||||
---|---|---|---|---|
| ||||
On Thursday, November 03, 2011 16:58 Lishaak Bystroushaak wrote: > Hello. > > Is there any way how to format date with formating strings? Something > like strftime in python; > http://docs.python.org/library/datetime.html#strftime-and-strptime-behavior Not currently. SysTime (and the other time point types in std.datetime) have functions for converting them to specific ISO standards but not custom formatting strings. That's in the works but hasn't been completed yet. In the meantime, you can get a time_t from a SysTime using its unixTime property and pass that to C's strftime (though be warned that it risks being an hour off on Windows, since for some bizarre reason Windows applies DST to UTC such that time_t on Windows isn't actually guaranteed to always be the number of seconds since midnight January 1st, 1970 in UTC). Another alternative is that someone ported the deprecated std.dateparse (which worked with the deprecated and very broken std.date) to use SysTime, and you can use that: https://gist.github.com/1283011 toCustomString will be added to SysTime and the other time point types in std.datetime, but its design hasn't been completed sorted out yet, let alone fully implemented, so it's in the works, but it could be a little while before it makes it into Phobos. - Jonathan M Davis |
November 04, 2011 Re: Formatted date | ||||
---|---|---|---|---|
| ||||
Oh, ok, thanks for your answer.
2011/11/4 Jonathan M Davis <jmdavisProg@gmx.com>:
> On Thursday, November 03, 2011 16:58 Lishaak Bystroushaak wrote:
>> Hello.
>>
>> Is there any way how to format date with formating strings? Something
>> like strftime in python;
>> http://docs.python.org/library/datetime.html#strftime-and-strptime-behavior
>
> Not currently. SysTime (and the other time point types in std.datetime) have functions for converting them to specific ISO standards but not custom formatting strings. That's in the works but hasn't been completed yet.
>
> In the meantime, you can get a time_t from a SysTime using its unixTime property and pass that to C's strftime (though be warned that it risks being an hour off on Windows, since for some bizarre reason Windows applies DST to UTC such that time_t on Windows isn't actually guaranteed to always be the number of seconds since midnight January 1st, 1970 in UTC).
>
> Another alternative is that someone ported the deprecated std.dateparse (which worked with the deprecated and very broken std.date) to use SysTime, and you can use that: https://gist.github.com/1283011
>
> toCustomString will be added to SysTime and the other time point types in std.datetime, but its design hasn't been completed sorted out yet, let alone fully implemented, so it's in the works, but it could be a little while before it makes it into Phobos.
>
> - Jonathan M Davis
>
|
December 01, 2011 Re: Formatted date | ||||
---|---|---|---|---|
| ||||
Posted in reply to Lishaak Bystroushaak | On 03/11/2011 23:58, Lishaak Bystroushaak wrote: > Hello. > > Is there any way how to format date with formating strings? <snip> Yes. See the datetime stuff in http://pr.stewartsplace.org.uk/d/sutil/ Stewart. |
December 01, 2011 Re: Formatted date | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan M Davis | On 04/11/2011 00:51, Jonathan M Davis wrote:
> On Thursday, November 03, 2011 16:58 Lishaak Bystroushaak wrote:
>> Hello.
>>
>> Is there any way how to format date with formating strings? Something
>> like strftime in python;
>> http://docs.python.org/library/datetime.html#strftime-and-strptime-behavior
>
> Not currently.
<snip>
I could've sworn it was you I was talking to about the stuff in my library before. Are you an imposter?
Stewart.
|
December 01, 2011 Re: Formatted date | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stewart Gordon | On Thursday, December 01, 2011 11:28:39 Stewart Gordon wrote:
> On 04/11/2011 00:51, Jonathan M Davis wrote:
> > On Thursday, November 03, 2011 16:58 Lishaak Bystroushaak wrote:
> >> Hello.
> >>
> >> Is there any way how to format date with formating strings? Something like strftime in python; http://docs.python.org/library/datetime.html#strftime-and-strptime-beh avior>
> > Not currently.
>
> <snip>
>
> I could've sworn it was you I was talking to about the stuff in my library before. Are you an imposter?
Why would I be an imposter?
- Jonathan M Davis
|
December 01, 2011 Re: Formatted date | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan M Davis | On 01/12/2011 16:44, Jonathan M Davis wrote: > On Thursday, December 01, 2011 11:28:39 Stewart Gordon wrote: <snip> >> I could've sworn it was you I was talking to about the stuff in my library >> before. Are you an imposter? > > Why would I be an imposter? If you weren't, you would already know about my library and not be posting under the premise that it doesn't exist. Stewart. |
December 01, 2011 Re: Formatted date | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stewart Gordon | On Thursday, December 01, 2011 22:33:00 Stewart Gordon wrote:
> On 01/12/2011 16:44, Jonathan M Davis wrote:
> > On Thursday, December 01, 2011 11:28:39 Stewart Gordon wrote:
> <snip>
>
> >> I could've sworn it was you I was talking to about the stuff in my library before. Are you an imposter?
> >
> > Why would I be an imposter?
>
> If you weren't, you would already know about my library and not be posting under the premise that it doesn't exist.
There's a halfway decent chance that I posted in this thread prior to reading anything about your library or before I looked at it at all.
- Jonathan M Davis
|
December 02, 2011 Re: Formatted date | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan M Davis | On 01/12/2011 22:57, Jonathan M Davis wrote:
<snip>
> There's a halfway decent chance that I posted in this thread prior to reading
> anything about your library or before I looked at it at all.
And both Lishaak's and your computers had their clocks set several days fast at the time?
Stewart.
|
December 02, 2011 Re: Formatted date | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stewart Gordon | On Friday, December 02, 2011 00:00:09 Stewart Gordon wrote:
> On 01/12/2011 22:57, Jonathan M Davis wrote:
> <snip>
>
> > There's a halfway decent chance that I posted in this thread prior to reading anything about your library or before I looked at it at all.
>
> And both Lishaak's and your computers had their clocks set several days fast at the time?
I have no idea when the discussion on your library was in d-announce. I'd have to go digging through the archives. I don't know what the exact situation was when I answered the OP's question in this thread. It was a month ago.
- Jonathan M Davis
|
Copyright © 1999-2021 by the D Language Foundation