From 3ec778133ff879aaad69606d3518e8ea7adf0bc6 Mon Sep 17 00:00:00 2001 From: Akira Kakuto Date: Mon, 3 Aug 2020 04:27:14 +0000 Subject: mplibdir: sync with upstream git-svn-id: svn://tug.org/texlive/trunk@56033 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/web2c/mplibdir/mp.w | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'Build/source') 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); -- cgit v1.2.3