[PATCH] D135045: [Frontend] Recognize environment variable SOURCE_DATE_EPOCH

Fangrui Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 11 11:34:19 PDT 2022


MaskRay marked 2 inline comments as done.
MaskRay added inline comments.


================
Comment at: clang/lib/Lex/PPMacroExpansion.cpp:1612
+      time_t TT = *getPreprocessorOpts().SourceDateEpoch;
+      std::tm *TM = std::gmtime(&TT);
       Result = asctime(TM);
----------------
ychen wrote:
> MaskRay wrote:
> > ychen wrote:
> > > To be consistent with existing code, it might be better to use `std::localtime` instead of `std::gmtime`?
> > No. This must use `std::gmtime`. localtime would introduce an undesired UTC time offset.
> Are you sure? https://linux.die.net/man/3/localtime  gmtime/localtime both accept a UTC time. I think the only difference is the time zone.
I'm sure. If you change this gmtime to localtime, for a timestamp which would otherwise display as 00:00:00, it would display as 16:00:00 if your timezone is UTC-0800.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135045/new/

https://reviews.llvm.org/D135045



More information about the cfe-commits mailing list