Issue 20038 - __DATE__ is in the wrong format for std.datetime.Date.from*
Summary: __DATE__ is in the wrong format for std.datetime.Date.from*
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: Other Linux
: P4 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-07-09 09:15 UTC by György Andrasek
Modified: 2024-12-01 16:35 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description György Andrasek 2019-07-09 09:15:29 UTC
I wanted to reproduce a Webpack feature of not working on Monday. I feel this should be enough:

```
int main(string[]) {
        import std.datetime;
        static assert(Date.fromSimpleString(__DATE__).dayOfWeek != DayOfWeek.mon);
        return 0;
}
```

Instead there's an error:

```
$ rdmd scratch.d
/data/data/com.termux/files/usr/bin/../include/d/std/datetime/date.d(7766): Error: uncaught CTFE exception core.time.TimeException("Invalid string format: Jul  9 2019"c)
scratch.d(3):        called from here: fromSimpleString("Jul  9 2019")
scratch.d(3):        while evaluating: static assert(cast(int)fromSimpleString("Jul  9 2019").dayOfWeek() != 1)
Failed: ["/data/data/com.termux/files/usr/bin/ldmd2", "-v", "-o-", "scratch.d", "-I."]
```
Comment 1 RazvanN 2023-04-18 12:04:49 UTC
This is not a compiler issue, rather than a phobos one. std.datetime lacks the functionality to transform a compiler provided date into an internal representation.
Comment 2 dlangBugzillaToGithub 2024-12-01 16:35:14 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/phobos/issues/10379

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB