summaryrefslogtreecommitdiff
path: root/Build/source
diff options
context:
space:
mode:
authorAkira Kakuto <kakuto@fuk.kindai.ac.jp>2020-08-03 04:27:14 +0000
committerAkira Kakuto <kakuto@fuk.kindai.ac.jp>2020-08-03 04:27:14 +0000
commit3ec778133ff879aaad69606d3518e8ea7adf0bc6 (patch)
treeca09c27d73b87c70e739a09e33943ccda99c4845 /Build/source
parentc18225d0fef967e7cdfa071e2b89276e05673f76 (diff)
mplibdir: sync with upstream
git-svn-id: svn://tug.org/texlive/trunk@56033 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source')
-rw-r--r--Build/source/texk/web2c/mplibdir/mp.w27
1 files changed, 25 insertions, 2 deletions
diff --git a/Build/source/texk/web2c/mplibdir/mp.w b/Build/source/texk/web2c/mplibdir/mp.w
index 69eeb571f8b..5f9f174172d 100644
--- a/Build/source/texk/web2c/mplibdir/mp.w
+++ b/Build/source/texk/web2c/mplibdir/mp.w
@@ -4379,9 +4379,32 @@ Note that the values are |scaled| integers. Hence \MP\ can no longer
be used after the year 32767.
@c
+#if defined(_MSC_VER)
+#define strtoull _strtoui64
+#endif
static void mp_fix_date_and_time (MP mp) {
- time_t aclock = time ((time_t *) 0);
- struct tm *tmptr = localtime (&aclock);
+ char *source_date_epoch;
+ time_t epoch;
+ char *endptr;
+ struct tm *tmptr;
+ source_date_epoch = getenv("SOURCE_DATE_EPOCH");
+ if (source_date_epoch) {
+ errno = 0;
+ epoch = strtoull(source_date_epoch, &endptr, 10);
+ if (*endptr != '\0' || errno != 0) {
+ FATAL1("invalid epoch-seconds-timezone value for environment variable $SOURCE_DATE_EPOCH: %s",
+ source_date_epoch);
+ }
+/* there is a limit 3001.01.01:2059 for epoch in Microsoft C */
+#if defined(_MSC_VER)
+ if (epoch > 32535291599ULL)
+ epoch = 32535291599ULL;
+#endif
+ tmptr = gmtime (&epoch);
+ } else {
+ epoch = time ((time_t *) 0);
+ tmptr = localtime (&epoch);
+ }
set_internal_from_number (mp_time, unity_t);
number_multiply_int (internal_value(mp_time), (tmptr->tm_hour * 60 + tmptr->tm_min));
set_internal_from_number (mp_hour, unity_t);