Effective String to Date conversion?

Mengu mengukagan at gmail.com
Mon Jan 29 00:14:50 UTC 2024


On Monday, 22 January 2024 at 10:56:04 UTC, atzensepp wrote:
> Dear D-gurus,
>
> being new to D I am trying my first steps and the language is 
> quite intuitive and appealing.
> When reading a file and creating a hash for the reocrds I want 
> to get only the most recent ones. For this I need to convert 
> Date/Time-Strings to comparable DateTime-Objects.
> The code below works but looks a bit clumsy. Is there a more 
> efficient (shorter) way to accomplish this?
>
> [...]

If your date conforms to an ISO or extended ISO format, you can 
use DateTime.fromISOString [0] or DateTime.fromISOExtString [1] 
functions.

[0] 
https://dlang.org/phobos/std_datetime_date.html#.Date.fromISOString
[1] 
https://dlang.org/phobos/std_datetime_date.html#.Date.fromISOExtString


More information about the Digitalmars-d-learn mailing list