[dmd-internals] How important are the exact formats of __DATE__, __TIME__, and __TIMESTAMP___?

Jonathan M Davis jmdavisProg at gmx.com
Tue Mar 8 19:36:51 PST 2011


Do they _have_ to be in a particular format? I ask because I've slowly been 
going through the lexer code, translating it to D for std.lang.d.lex, and I'm 
very tempted to just use std.datetime to produce the values for __DATE__, 
__TIME__, __TIMESTAMP__. The resulting values would look cleaner IMHO, and the 
code would be simpler. However, that _would_ result in a slightly different 
format for __DATE__ and __TIMESTAMP__.

Honestly, I didn't even know that these "macros" existed before I ran into them 
in the lexer - there's no mention of them on the site as far as I can determine. 
So, I have no idea whether they're exact format is considered important and part 
of the spec or not. If the format _is_ important, then I might as well leave it 
and have the D code call time and ctime as it does in the C++ code, but I'd just 
as soon use std.datetime if the format doesn't have to be absolutely exact.

So, are the formats of __DATE__, __TIME__, and __TIMESTAMP__ exact such that 
they should _always_ be as they currently are in the C++ lexer, or are they 
flexible enough that I can just simplify the code in the D lexer with 
std.datetime?

- Jonathan M Davis


More information about the dmd-internals mailing list