FreeBSD Bugzilla – Attachment 6140 Details for
Bug 14151
Patch: date(1): merge in OpenBSD enhancements
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
file.diff
file.diff (text/plain), 7.66 KB, created by
Christian Weisgerber
on 1999-10-06 02:40:00 UTC
(
hide
)
Description:
file.diff
Filename:
MIME Type:
Creator:
Christian Weisgerber
Created:
1999-10-06 02:40:00 UTC
Size:
7.66 KB
patch
obsolete
>diff -ur date.orig/date.1 date/date.1 >--- date.orig/date.1 Sat Aug 28 01:13:58 1999 >+++ date/date.1 Wed Oct 6 00:33:40 1999 >@@ -35,7 +35,7 @@ > .\" @(#)date.1 8.3 (Berkeley) 4/28/95 > .\" $FreeBSD: src/bin/date/date.1,v 1.31 1999/08/27 23:13:58 peter Exp $ > .\" >-.Dd November 17, 1993 >+.Dd April 28, 1995 > .Dt DATE 1 > .Os > .Sh NAME >@@ -49,26 +49,29 @@ > .Op Fl t Ar minutes_west > .Op Fl v Ns Ar [+|-]val Ns Op ymwdHMS > .Ar ... >-.Op Fl f Ar fmt Ar date | [[[[yy]mm]dd]HH]MM[\&.ss] >+.Op Fl f Ar fmt Ar date | [[[[[cc]yy]mm]dd]HH]MM[\&.ss] > .Op Cm + Ns Ar format > .Sh DESCRIPTION >-.Nm Date >-displays the current date and time when invoked without arguments. >-Providing arguments will format the date and time in a user-defined >-way or set the date. >-Only the superuser may set the date. >+When invoked without arguments, the >+.Nm >+utility displays the current date and time. >+Otherwise, depending on the options specified, >+.Nm >+will set the date and time or print it in a user-defined way. >+.Pp >+Only the super-user may set the date. > .Pp > The options are as follows: > .Bl -tag -width Ds >-.It Fl d >-Set the kernel's value for daylight savings time. >+.It Fl d Ar dst >+Set the kernel's value for daylight saving time. > If > .Ar dst > is non-zero, future calls > to > .Xr gettimeofday 2 > will return a non-zero >-.Ql tz_dsttime . >+.Ql tz_dsttime . > .It Fl f > Use > .Ar fmt >@@ -88,7 +91,7 @@ > .Xr timed 8 > is used to synchronize the clocks on groups of machines. > By default, if >-.Xr timed >+.Xr timed 8 > is running, > .Nm > will set the time on all of the machines in the local group. >@@ -97,23 +100,23 @@ > option stops > .Nm > from setting the time for other than the current machine. >-.It Fl r >-Print out the date and time in >+.It Fl r Ar seconds >+Print out (in specified format) the date and time represented by > .Ar seconds > from the Epoch. >-.It Fl t >+.It Fl t Ar minutes_west > Set the kernel's value for minutes west of > .Tn GMT . >-.Ar Minutes_west >+.Ar minutes_west > specifies the number of minutes returned in >-.Ql tz_minuteswest >+.Ql tz_minuteswest > by future calls to > .Xr gettimeofday 2 . > .It Fl u > Display or set the date in >-.Tn UCT >+.Tn UTC > (universal) time. >-.It Fl v >+.It Fl v Ns Ar [+|-]val Ns Op ymwdHMS > Adjust the second, minute, hour, month day, week day, month or year according to > .Ar val . > If >@@ -150,10 +153,12 @@ > Refer to the examples below for further details. > .El > .Pp >-An operand with a leading plus (``+'') sign signals a user-defined format >+An operand with a leading plus sign >+.Pq Sq + >+signals a user-defined format > string which specifies the format in which to display the date and time. > The format string may contain any of the conversion specifications described >-in the >+in the > .Xr strftime 3 > manual page, as well as any arbitrary text. > A <newline> character is always output after the characters specified by >@@ -169,24 +174,26 @@ > .Pp > .Bl -tag -width Ds -compact -offset indent > .It Ar yy >-Year in abbreviated form (e.g. 89 for 1989, 06 for 2006). >+Year in abbreviated form (for years falling within 1969\(em2068). >+The format >+.Ar ccyymmddHHMM >+is also permitted, for non-ambiguous years. > .It Ar mm >-Numeric month. >-A number from 1 to 12. >+Numeric month, a number from 1 to 12. > .It Ar dd > Day, a number from 1 to 31. > .It Ar HH > Hour, a number from 0 to 23. > .It Ar MM >-Minutes, a number from 0 to 59. >-.It Ar .ss >-Seconds, a number from 0 to 61 (59 plus a maximum of two leap seconds). >+Minute, a number from 0 to 59. >+.It Ar .SS >+Second, a number from 0 to 61 (59 plus a maximum of two leap seconds). > .El > .Pp >-Everything but the minutes is optional. >+Everything but the minute is optional. > .Pp >-Time changes for Daylight Saving and Standard time and leap seconds >-and years are handled automatically. >+Time changes for daylight saving time, standard time, leap seconds, >+and leap years are handled automatically. > .Sh EXAMPLES > The command: > .Bd -literal -offset indent >@@ -250,9 +257,8 @@ > .Li "2:32 PM" , > without modifying the date. > .Sh ENVIRONMENT >-The execution of >-.Nm >-is affected by the following environment variables: >+The following environment variables affect the execution of >+.Nm date : > .Bl -tag -width Ds > .It Ev TZ > The timezone to use when displaying dates. >@@ -268,9 +274,9 @@ > .Sh FILES > .Bl -tag -width /var/log/messages -compact > .It Pa /var/log/wtmp >-a record of date resets and time changes >+record of date resets and time changes > .It Pa /var/log/messages >-a record of the user setting the time >+record of the user setting the time > .El > .Sh SEE ALSO > .Xr gettimeofday 2 , >@@ -290,25 +296,25 @@ > if able to set the local date, but unable to set it globally. > .Pp > Occasionally, when >-.Xr timed >+.Xr timed 8 > synchronizes the time on many hosts, the setting of a new time value may > require more than a few seconds. > On these occasions, > .Nm > prints: >-.Ql Network time being set . >+.Dq Network time being set . > The message >-.Ql Communication error with timed >+.Dq Communication error with timed > occurs when the communication > between > .Nm > and >-.Xr timed >+.Xr timed 8 > fails. > .Sh STANDARDS > The > .Nm >-command is expected to be compatible with >+utility is expected to be compatible with > .St -p1003.2 . > .Sh HISTORY > A >diff -ur date.orig/date.c date/date.c >--- date.orig/date.c Sat Aug 28 01:13:59 1999 >+++ date/date.c Wed Oct 6 00:13:54 1999 >@@ -50,16 +50,21 @@ > > #include <ctype.h> > #include <err.h> >+#include <libutil.h> >+#include <locale.h> > #include <stdio.h> > #include <stdlib.h> > #include <string.h> > #include <syslog.h> > #include <unistd.h> >-#include <locale.h> > > #include "extern.h" > #include "vary.h" > >+#ifndef TM_YEAR_BASE >+#define TM_YEAR_BASE 1900 >+#endif >+ > time_t tval; > int retval; > >@@ -67,8 +72,6 @@ > static void badformat __P((void)); > static void usage __P((void)); > >-int logwtmp __P((char *, char *, char *)); >- > int > main(argc, argv) > int argc; >@@ -121,7 +124,7 @@ > usage(); > set_timezone = 1; > break; >- case 'u': /* do everything in GMT */ >+ case 'u': /* do everything in UTC */ > (void)setenv("TZ", "GMT0", 1); > break; > case 'v': >@@ -184,6 +187,8 @@ > register struct tm *lt; > struct timeval tv; > const char *dot, *t; >+ int bigyear; >+ int yearset = 0; > > if (fmt != NULL) { > lt = localtime(&tval); >@@ -221,20 +226,31 @@ > > /* if p has a ".ss" field then let's pretend it's not there */ > switch (strlen(p) - ((dot != NULL) ? 3 : 0)) { >+ case 12: /* cc */ >+ bigyear = ATOI2(p); >+ lt->tm_year = bigyear * 100 - TM_YEAR_BASE; >+ yearset = 1; >+ /* FALLTHROUGH */ > case 10: /* yy */ >- lt->tm_year = ATOI2(p); >- if (lt->tm_year < 69) /* hack for 2000 ;-} */ >- lt->tm_year += 100; >+ if (yearset) { >+ lt->tm_year += ATOI2(p); >+ } else { >+ lt->tm_year = ATOI2(p); >+ if (lt->tm_year < 69) /* hack for 2000 ;-} */ >+ lt->tm_year += (2000 - TM_YEAR_BASE); >+ else >+ lt->tm_year += (1900 - TM_YEAR_BASE); >+ } > /* FALLTHROUGH */ > case 8: /* mm */ > lt->tm_mon = ATOI2(p); >- if (lt->tm_mon > 12) >+ if ((lt->tm_mon > 12) || !lt->tm_mon) > badformat(); > --lt->tm_mon; /* time struct is 0 - 11 */ > /* FALLTHROUGH */ > case 6: /* dd */ > lt->tm_mday = ATOI2(p); >- if (lt->tm_mday > 31) >+ if ((lt->tm_mday > 31) || !lt->tm_mday) > badformat(); > /* FALLTHROUGH */ > case 4: /* HH */ >@@ -254,7 +270,7 @@ > > /* convert broken-down time to GMT clock time */ > if ((tval = mktime(lt)) == -1) >- errx(1, "nonexistent time"); >+ errx(1, "specified date is outside allowed range"); > > if (!jflag) { > /* set the time */ >@@ -286,6 +302,7 @@ > (void)fprintf(stderr, "%s\n%s\n", > "usage: date [-nu] [-d dst] [-r seconds] [-t west] " > "[-v[+|-]val[ymwdHMS]] ... ", >- " [-f fmt date | [[[[yy]mm]dd]HH]MM[.ss]] [+format]"); >+ " [-f fmt date | [[[[[cc]yy]mm]dd]HH]MM[.ss]] " >+ "[+format]"); > exit(1); > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 14151
: 6140