std.datetime: easy way to parse 24/Jun/2020?
Steven Schveighoffer
schveiguy at gmail.com
Mon Jun 29 00:55:17 UTC 2020
On 6/28/20 8:42 PM, Andrei Alexandrescu wrote:
> The day and year obviously are easy, is there a way to easily parse the
> month from English into number? Thanks!
std.datetime specifically does not deal with parsing all formats
(generally, this is a HUGE amount of work).
It has 2 parsing formats (3 actually, if you can't the non-EXT and EXT
ISO formats):
https://dlang.org/phobos/std_datetime_date.html#.DateTime.fromSimpleString,
https://dlang.org/phobos/std_datetime_date.html#.DateTime.fromISOExtString
Otherwise, you have to do it yourself.
Note that the 3-letter english name (not capitalized) might match the
Month enum: https://dlang.org/phobos/std_datetime_date.html#Month, which
means you could possibly parse it with formattedRead.
There are also dub packages, e.g.:
https://code.dlang.org/packages/dateparser
-Steve
More information about the Digitalmars-d
mailing list