texlive[61833] Build/source/texk/web2c/hitexdir/hitex.w: making hitex

commits+mruckert at tug.org commits+mruckert at tug.org
Tue Feb 1 10:14:42 CET 2022


Revision: 61833
          http://tug.org/svn/texlive?view=revision&revision=61833
Author:   mruckert
Date:     2022-02-01 10:14:42 +0100 (Tue, 01 Feb 2022)
Log Message:
-----------
making hitex use localtime if FORCE_SOURCE_DATE is not set to 1

Modified Paths:
--------------
    trunk/Build/source/texk/web2c/hitexdir/hitex.w

Modified: trunk/Build/source/texk/web2c/hitexdir/hitex.w
===================================================================
--- trunk/Build/source/texk/web2c/hitexdir/hitex.w	2022-02-01 00:50:47 UTC (rev 61832)
+++ trunk/Build/source/texk/web2c/hitexdir/hitex.w	2022-02-01 09:14:42 UTC (rev 61833)
@@ -5462,13 +5462,13 @@
 @^creation date@>
 @^reference time@>
 @^system dependencies@>
-k\TeX\ calls |tl_now| to obtain the current time (UTC) as a |tm| structure.
+k\TeX\ calls |tl_now| to obtain the current time as a |tm| structure.
 @p static void fix_date_and_time(void)
-{@+ struct tm *gmt=tl_now();
-  time=sys_time= gmt->tm_hour*60+gmt->tm_min;/*minutes since midnight*/
-  day=sys_day= gmt->tm_mday;/*day of the month*/
-  month=sys_month=gmt->tm_mon+1;/*month of the year*/
-  year=sys_year=gmt->tm_year+1900;/*Anno Domini*/
+{@+ struct tm *t=tl_now();
+  time=sys_time= t->tm_hour*60+t->tm_min;/*minutes since midnight*/
+  day=sys_day= t->tm_mday;/*day of the month*/
+  month=sys_month=t->tm_mon+1;/*month of the year*/
+  year=sys_year=t->tm_year+1900;/*Anno Domini*/
 }
 
 @ @<Show equivalent |n|, in region 5@>=
@@ -34717,17 +34717,24 @@
 @ We conclude this chapter using \.{time.h} to provide a function
 that is used to initialize
 \TeX's date and time information. Because |time| is one of \TeX's
-macros, we add the function |tl_now| that wraps the call to |time|
-(and |gmtime|) for later use in |fix_date_and_time|.
+macros, we add the function |tl_now| before including \TeX's macros
+to wrap the call to the |time| function.
+It sets the variable |start_time| and returns a pointer to a |tm| structure
+to be used later in |fix_date_and_time|.
 
-To support \LaTeX, two environment variables need to be checked:
-If |SOURCE_DATE_EPOCH| is set, it is used as the current time in
-seconds since January 1, 1970 (UTC).
-If |FORCE_SOURCE_DATE| is set to $1$ also \TeX's primitives
-\.{\\year}, \.{\\month}, \.{\\day}, and \.{\\time} use this value
-as the current time. This feature is usefull to make reproducible
-builds of documents.
+To support reproducible output, the environment variable |SOURCE_DATE_EPOCH|
+needs to be checked. If it is set, it is an \ASCII\ representation of
+a \UNIX\ timestamp, defined as the number
+of seconds, excluding leap seconds, since 01 Jan 1970 00:00:00 UTC.
+Its value is then used to initialize the |start_time| variable.
 
+The \TeX\ Live conventions further require that setting the
+|FORCE_SOURCE_DATE| environment variable to $1$ will cause also \TeX's primitives
+\.{\\year}, \.{\\month}, \.{\\day}, and \.{\\time}  to use this value
+as the current time. Looking at the \TeX\ Live code also reveals that
+these primitives use the local time instead of the GMT if this variable is
+not set to~1.
+
 @<Header files and function declarations@>=
 #include <time.h>
 static time_t start_time = ((time_t)-1);
@@ -34738,22 +34745,28 @@
 #endif
 
 static struct tm *tl_now(void)
-{@+struct tm *gmt;
+{@+struct tm *tp;
    time_t t;
    source_date_epoch= getenv("SOURCE_DATE_EPOCH");
+   force_source_date= getenv("FORCE_SOURCE_DATE");
+   if (force_source_date!=NULL &&
+       (force_source_date[0]!='1' || force_source_date[1]!=0))
+       force_source_date=NULL;
+
    if (source_date_epoch!=NULL)
-   { start_time= (time_t)strtoull(source_date_epoch, NULL, 10);
-     force_source_date= getenv ("FORCE_SOURCE_DATE");
-     if (force_source_date!=NULL &&
-         force_source_date[0]=='1' && force_source_date[1]==0)
+   {  start_time= (time_t)strtoull(source_date_epoch, NULL, 10);
+      if (force_source_date!=NULL)
          t=start_time;
-       else
+      else
          t=time(NULL);
    }
    else
      t=start_time=time(NULL);
-  gmt=gmtime(&t);
-  return gmt;
+   if (force_source_date)
+     tp=gmtime(&t);
+   else
+     tp=localtime(&t);
+  return tp;
 }
 
 @ To support \LaTeX, a few more time related functions are needed.



More information about the tex-live-commits mailing list.