digitalmars.D - std.datetime: easy way to parse 24/Jun/2020?
- Andrei Alexandrescu (2/2) Jun 28 2020 The day and year obviously are easy, is there a way to easily parse the
- Stanislav Blinov (5/7) Jun 28 2020 There's [1] if you're willing to transform the input.
- Steven Schveighoffer (14/16) Jun 28 2020 std.datetime specifically does not deal with parsing all formats
- Walter Bright (3/5) Jun 28 2020 The old D1 std.datetime does it using compiler lexing techniques:
- Seb (3/5) Jun 28 2020 https://code.dlang.org/packages/dateparser
The day and year obviously are easy, is there a way to easily parse the month from English into number? Thanks!
Jun 28 2020
On Monday, 29 June 2020 at 00:42:17 UTC, Andrei Alexandrescu wrote:The day and year obviously are easy, is there a way to easily parse the month from English into number? Thanks!There's [1] if you're willing to transform the input. [1] https://dlang.org/library/std/datetime/date/date.from_simple_string.html
Jun 28 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
Jun 28 2020
On 6/28/2020 5: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!The old D1 std.datetime does it using compiler lexing techniques: https://github.com/dlang/undeaD/blob/master/src/undead/dateparse.d
Jun 28 2020
On Monday, 29 June 2020 at 00:42:17 UTC, Andrei Alexandrescu wrote:The day and year obviously are easy, is there a way to easily parse the month from English into number? Thanks!https://code.dlang.org/packages/dateparser
Jun 28 2020