ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/src/vendor/FreeBSD/dist/bin/date/date.c
(Generate patch)

Comparing vendor/FreeBSD/dist/bin/date/date.c (file contents):
Revision 9656 by laffer1, Sun Oct 22 21:03:47 2017 UTC vs.
Revision 9657 by laffer1, Sun Oct 22 21:36:58 2017 UTC

# Line 40 | Line 40 | static char sccsid[] = "@(#)date.c     8.2 (Berkeley) 4/28
40   #endif
41  
42   #include <sys/cdefs.h>
43 < __FBSDID("$FreeBSD: release/7.0.0/bin/date/date.c 139969 2005-01-10 08:39:26Z imp $");
43 > __FBSDID("$FreeBSD$");
44  
45   #include <sys/param.h>
46   #include <sys/time.h>
# Line 48 | Line 48 | __FBSDID("$FreeBSD: release/7.0.0/bin/date/date.c 1399
48   #include <ctype.h>
49   #include <err.h>
50   #include <locale.h>
51 #include <libutil.h>
51   #include <stdio.h>
52   #include <stdlib.h>
53   #include <string.h>
54   #include <syslog.h>
55   #include <unistd.h>
56 + #include <utmpx.h>
57  
58   #include "extern.h"
59   #include "vary.h"
# Line 181 | Line 181 | main(int argc, char *argv[])
181   static void
182   setthetime(const char *fmt, const char *p, int jflag, int nflag)
183   {
184 +        struct utmpx utx;
185          struct tm *lt;
186          struct timeval tv;
187          const char *dot, *t;
188          int century;
189  
190 +        lt = localtime(&tval);
191 +        lt->tm_isdst = -1;              /* divine correct DST */
192 +
193          if (fmt != NULL) {
190                lt = localtime(&tval);
194                  t = strptime(p, fmt, lt);
195                  if (t == NULL) {
196                          fprintf(stderr, "Failed conversion of ``%s''"
# Line 208 | Line 211 | setthetime(const char *fmt, const char *p, int jflag,
211                          badformat();
212                  }
213  
211                lt = localtime(&tval);
212
214                  if (dot != NULL) {                      /* .ss */
215                          dot++; /* *dot++ = '\0'; */
216                          if (strlen(dot) != 2)
# Line 264 | Line 265 | setthetime(const char *fmt, const char *p, int jflag,
265                  }
266          }
267  
267        /* Let mktime() decide whether summer time is in effect. */
268        lt->tm_isdst = -1;
269
268          /* convert broken-down time to GMT clock time */
269          if ((tval = mktime(lt)) == -1)
270                  errx(1, "nonexistent time");
# Line 274 | Line 272 | setthetime(const char *fmt, const char *p, int jflag,
272          if (!jflag) {
273                  /* set the time */
274                  if (nflag || netsettime(tval)) {
275 <                        logwtmp("|", "date", "");
275 >                        utx.ut_type = OLD_TIME;
276 >                        gettimeofday(&utx.ut_tv, NULL);
277 >                        pututxline(&utx);
278                          tv.tv_sec = tval;
279                          tv.tv_usec = 0;
280                          if (settimeofday(&tv, (struct timezone *)NULL))
281                                  err(1, "settimeofday (timeval)");
282 <                        logwtmp("{", "date", "");
282 >                        utx.ut_type = NEW_TIME;
283 >                        gettimeofday(&utx.ut_tv, NULL);
284 >                        pututxline(&utx);
285                  }
286  
287                  if ((p = getlogin()) == NULL)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines