Thread overview
std.datetime: easy way to parse 24/Jun/2020?
Jun 29
Seb
June 28
The day and year obviously are easy, is there a way to easily parse the month from English into number? Thanks!
June 29
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
June 28
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
June 28
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
June 29
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