[boost::date_time] posix_time::to_simple_string and posix_time::time_from_string
These 2 functions don't seem to work together. to_simple_string will produce a string such as 2003-Jul-08 11:55:47 But time_from_string expects 2003-07-08 11:55:47 This means you can't convert to a string (to store in a text file) then read back in and convert it back to a ptime. Is this a bug, or have I missed a conversion function that can handle this? Thanks Russell
On Tue, 08 Jul 2003 12:07:24 +0100, Russell Hind wrote
These 2 functions don't seem to work together.
to_simple_string will produce a string such as
2003-Jul-08 11:55:47
But time_from_string expects
2003-07-08 11:55:47
This means you can't convert to a string (to store in a text file) then read back in and convert it back to a ptime.
Is this a bug, or have I missed a conversion function that can handle this?
No, this was brought up recently on the developer list. Take a look at this message from the archive: http://aspn.activestate.com/ASPN/Mail/Message/1686681 Jeff
Jeff Garland wrote:
No, this was brought up recently on the developer list. Take a look at this message from the archive:
Thanks Jeff. Have you any plans to address this in a future release (and if so, which way will you go?) Your suggested method would output the string as 2003-07-08 .... But I quite like having the 3 letter month name in there. Living in the UK, theres always confustion as to whether the day was before the month or not. I know that when the year comes first, the month comes second but having the month spelled out just removes any chance of this. For now, I'll implement my own time_from_string method that handles the month as 3 characters. Cheers Russell
On Tue, 08 Jul 2003 14:36:33 +0100, Russell Hind wrote
Jeff Garland wrote:
No, this was brought up recently on the developer list. Take a look at this message from the archive:
Thanks Jeff. Have you any plans to address this in a future release (and if so, which way will you go?)
I'm a little worried about breaking existing code, so I think the right thing would be to modify the input to accept either a string or an integer month in the from_simple_string.
Your suggested method would output the string as
2003-07-08 ....
But I quite like having the 3 letter month name in there. Living in the UK, theres always confustion as to whether the day was before the month or not. I know that when the year comes first, the month comes second but having the month spelled out just removes any chance of this.
I agree totally with this -- it is the reason why the output includes the 3 letter month. Unfortunately, I didn't make it consistent...
For now, I'll implement my own time_from_string method that handles the month as 3 characters.
When you get it working, ship it to me and I will work on including it in the next release... Jeff
participants (2)
-
Jeff Garland
-
Russell Hind