-
-
Notifications
You must be signed in to change notification settings - Fork 684
Closed
Description
Introduced in #11035
$ cat test.c
#include <stdio.h>
void main() { printf(__DATE__ " " __TIME__ "\n"); }
$ SOURCE_DATE_EPOCH=1 gcc test.c -o test-c
$ ./test-c
Jan 1 1970 00:00:01$ cat test.d
import core.stdc.stdio;
void main() { printf(__DATE__ ~ " " ~ __TIME__ ~ "\n"); }
$ SOURCE_DATE_EPOCH=1 dmd test.d -oftest-d
$ ./test-d
Dec 31 1969 16:00:01This is because implementation uses ctime.
dmd/compiler/src/dmd/globals.d
Lines 411 to 419 in 47f8ee4
| // https://issues.dlang.org/show_bug.cgi?id=20444 | |
| if (auto p = getenv("SOURCE_DATE_EPOCH")) | |
| { | |
| if (!ct.parseDigits(p[0 .. strlen(p)])) | |
| errorSink.error(Loc.initial, "value of environment variable `SOURCE_DATE_EPOCH` should be a valid UNIX timestamp, not: `%s`", p); | |
| } | |
| else | |
| core.stdc.time.time(&ct); | |
| const p = ctime(&ct); |
The call
ctime(t)is equivalent toasctime(localtime(t)).
Because explicitly setting SOURCE_DATE_EPOCH is asking for a fixed time, the implementation should instead be calling asctime(gmtime(t)).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels