Thread overview | |||||
---|---|---|---|---|---|
|
June 27, 2015 string to time conversion (when string contains time but no date) | ||||
---|---|---|---|---|
| ||||
Attachments:
| is there a way to convert a string representing a time (without date) to a time, eg: auto t = "19:03:40.143656"; auto a=SysTime.fromTimeString(t); // doesn't exist My current workaround is to append a dummy date before and then calling SysTime.fromSimpleString. Is there a better way? seems needed |
June 27, 2015 Re: string to time conversion (when string contains time but no date) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Timothee Cour | On Saturday, 27 June 2015 at 03:17:49 UTC, Timothee Cour wrote: > is there a way to convert a string representing a time (without date) to a > time, eg: > > auto t = "19:03:40.143656"; > auto a=SysTime.fromTimeString(t); // doesn't exist > > > My current workaround is to append a dummy date before and then calling SysTime.fromSimpleString. > > Is there a better way? seems needed Try TimeOfDay's methods: http://dlang.org/phobos/std_datetime.html#.TimeOfDay.fromISOString http://dlang.org/phobos/std_datetime.html#.TimeOfDay.fromISOExtString |
June 27, 2015 Re: string to time conversion (when string contains time but no date) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Marc Schütz Attachments:
| thanks, missed that! On Sat, Jun 27, 2015 at 2:59 AM, via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > On Saturday, 27 June 2015 at 03:17:49 UTC, Timothee Cour wrote: > >> is there a way to convert a string representing a time (without date) to a >> time, eg: >> >> auto t = "19:03:40.143656"; >> auto a=SysTime.fromTimeString(t); // doesn't exist >> >> >> My current workaround is to append a dummy date before and then calling SysTime.fromSimpleString. >> >> Is there a better way? seems needed >> > > Try TimeOfDay's methods: > > http://dlang.org/phobos/std_datetime.html#.TimeOfDay.fromISOString http://dlang.org/phobos/std_datetime.html#.TimeOfDay.fromISOExtString > |
Copyright © 1999-2021 by the D Language Foundation