[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference turris::digital_unix

Title:DIGITAL UNIX(FORMERLY KNOWN AS DEC OSF/1)
Notice:Welcome to the Digital UNIX Conference
Moderator:SMURF::DENHAM
Created:Thu Mar 16 1995
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:10068
Total number of notes:35879

9050.0. "Set date to yr beyond 2000" by ZPOVC::YINGYONG () Wed Mar 05 1997 22:00

    The 'date' command allows only 2 digits yy to specify the year.  How do
    I set the date to the year beyond 2000 ?
    
    I am using Unix 4.0a which is supposed to be yr. 2000 compliant, is
    that right ?
    
    Rgds.
T.RTitleUserPersonal
Name
DateLines
9050.1Have you tried reading the man page? :-)VAXCPU::michaudJeff Michaud - ObjectBrokerThu Mar 06 1997 00:23399


date(1)								      date(1)



NAME
  date - Displays or sets the date

SYNOPSIS

  Without Superuser Authority -	Displays the Date


  date [-u] [+field_descriptor ...]

  With Superuser Authority - Sets the Date


  date [-nu] [MMddhhmm.ssyy | alternate_date_format] [+field_descriptor	...]

  Using	XPG4-UNIX - Sets the Date


  date [mmddHHMM[yy]

  Using	the Century Field Provided by Digital -	Sets the Date


  date mmddHHMM[[cc]yy][.ss]
  date [[cc]yy]mmddHHMM[.ss]
  date mmddHHMM[.ss[[cc]yy]]

STANDARDS

  Interfaces documented	on this	reference page conform to industry standards
  as follows:

  date:	 XPG4, XPG4-UNIX

  Refer	to the standards(5) reference page for more information	about indus-
  try standards	and associated tags.

DESCRIPTION

  The date command displays the	date and, with superuser authority, sets the
  system date. The date	command	has been enhanced to support setting the sys-
  tem date past	the year 1999, thus providing customers	with the ability to
  begin	testing	their software for potential century rollover problems.

  Displaying the Date

  The date command writes the current date and time to standard	output if
  called with no flags or with a flag list that	begins with a +	(plus sign).

  If you follow	date with a + (plus sign) and a	field descriptor, you can
  control the output of	the command.  You must precede each field descriptor
  with a % (percent sign).  The	system replaces	the field descriptor with the
  specified value.  Enter a literal % as %%.  The date command copies any
  other	characters to standard output without change. The date command always
  ends the string with a newline character.  Output fields are fixed size
  (zero	padded if necessary).

  [Digital]  The date command prints out a usage message on any	unrecognized
  flags	or input.

  Field	Descriptors


  a   Displays the locale's abbreviated	weekday	name (Sun to Sat or the	non-
      English equivalent).

  A   Displays the locale's full weekday name.

  b   Displays the locale's abbreviated	month name.

  B   Displays the locale's full month name.

  c   Displays the locale's appropriate	time and date representation.

  C   Displays the locale's century (the year divided by 100 and truncated to
      an integer) as a decimal number (00 to 99).

  d   Displays the day of month	as a decimal number (01	to 31).

  D   Displays the date	in the format mm/dd/yy independent of the value
      specified	by the LC_TIME environment variable, if	defined.

  e   Displays the day of the month as a decimal number	(1 to 31 in a 2-digit
      field with leading space fill).

  Ec  Specifies	the locale's alternative date and time representation.

  EC  Specifies	the name of the	base year (period) in the locale's alterna-
      tive representation.

  Ex  Specifies	the locale's alternative date representation.

  EX  Specifies	the locale's alternative time representation.

  Ey  Specifies	the offset from	%EC (year only)	in the locale's	alternative
      representation.

  EY  Specifies	the full alternative year representation.

  h   A	synonym	for %b.

  H   Displays the hour	as a decimal number (00	to 23).

  I   Displays the hour	as a decimal number (01	to 12).

  j   Displays the day of year as a decimal number (001	to 366).

  m   Displays the month of year as a decimal number (01 to 12).

  M   Displays the minute as a decimal number (00 to 59).

  n   Inserts a	newline	character.

  N   [Digital]	 Represents the	alternative era	name.

  o   [Digital]	 Represents the	alternative era	year.

  Od  Specifies	the day	of the month using the locale's	alternative numeric
      symbols.

  Oe  Specifies	the day	of the month using the locale's	alternative numeric
      symbols.

  OH  Specifies	the hour (24-hour clock) using the locale's alternative
      numeric symbols.

  OI  Specifies	the hour (12-hour clock) using the locale's alternative
      numeric symbols.

  Om  Specifies	the month using	the locale's alternative numeric symbols.

  OM  Specifies	the minutes using the locale's alternative numeric symbols.

  OS  Specifies	the seconds using the locale's alternative numeric symbols.

  Ou  Specifies	the weekday as a number	in the locale's	alternative represen-
      tation (Monday=1).

  OU  Specifies	the week number	of the year (Sunday as the first day of	the
      week) using the locale's alternative numeric symbols.

  Ow  Specifies	the weekday as a number	in the locale's	alternative represen-
      tation (Sunday = 0).

  OW  Specifies	the week number	of the year (Monday as the first day of	the
      week) using the locale's alternative numeric symbols.

  Oy  Specifies	the year (offset from %C) in alternative representation.

  p   Displays the locale's equivalent of either AM or PM.

  r   Displays the time	(12-hour clock)	using AM/PM notation (or the non-
      English equivalent) in the format	hh:mm:ss AM or hh:mm:ss	PM.

  S   Displays the second as a decimal number (00 to 61).

  t   Inserts a	tab character.

  T   Displays the time	in 24-hour clock format	as hh:mm:ss (the default), or
      as specified by the LC_TIME environment variable,	if defined.

  u   Displays the weekday as a	decimal	number [1,7], with 1 representing
      Monday.

  U   Displays the week	number of the year (Sunday is the first	day of the
      week) as a decimal number	(00 to 53).  All days in a new year preceding
      the first	Sunday are considered to be in week 0.

  V   Displays the week	number of the year (Monday as the first	day of the
      week) as a decimal number	(01 to 53).  If	the week containing January 1
      has four or more days in the new year, then it is	considered week	1;
      otherwise, it is week 53 or the previous year, and the next week is
      week 1.

  w   Displays the day of the week as a	decimal	number (Sunday = 0).

  W   Displays the week	number of the year (Monday is the first	day of the
      week) as a decimal number	(00 to 53).  All days in a new year preceding
      the first	Monday are considered to be in week 0.

  x   Displays the locale's appropriate	date representation.

  X   Displays the locale's appropriate	time representation.

  y   Displays the last	two numbers of the year	as a decimal number (00	to
      99).

  Y   Displays the full	year as	a decimal number.

  Z   Displays the time	zone name, or no characters if the time	zone cannot
      be determined.

  %%  Inserts a	% character.

  Setting the Date


  Only a user operating	with superuser authority can change the	date and
  time.

  The default input format for setting the date	is mmddHHMM[[cc]yy][.ss]
  where:

    +  mm is the month number (01=January).

    +  dd is the number	of the day in the month.

    +  HH is the hour in the day (using	a 24-hour clock).

    +  MM is the number	of minutes.

    +  cc is the first two digits of the year.

    +  yy is the last two digits of the	year.  If this field is	omitted, the
       current year is used.

    +  ss is the number	of seconds.

  Note that the	LC_TIME	variable, if defined, controls the ordering of the
  day (dd) and month (mm) numbers in these formats.  The default order is the
  month	(mm) followed by the day (dd).

  Each of the Digital formats allows you to specify the	century	(first two
  digits of the	year).	This century field (cc)	is optional to ensure that
  input	formats	previously accepted by the date	command	are still supported.

  Currently, the XPG4-UNIX format does not have	a century field.  This is
  consistent with current X/Open specifications	regarding the date command.
  The century field will be added to this format in a future release of	the
  operating system once	this new field is officially supported in future
  revisions of X/Open's	UNIX specification.

  [Digital]  Reset the date in single-user mode	only. Changing the date	in
  multiuser mode could cause the creation and modifications dates for user
  files	to be inconsistent.

  [Digital]  To	change the year, the system disk must be updated with the new
  year information. To change the year,	in single-user mode enter the com-
  mand:

       mount -u	/

  after	you enter a date containing a new year.	The mount -u / command writes
  the new year into the	superblock on the system disk. The root	filesystem is
  now mounted read/write.

  Handling of Two-Digit	Year Input

  When the year	is specified using two digits (as in the XPG4-UNIX format or
  when the [cc]	field is omitted from the Digital formats), the	century	is
  determined in	the following manner: if the specified two-digit year is
  between 69 and 99 inclusive, the 20th	century	is assumed (that is, 19yy);
  otherwise, the 21st century is assumed (that is, 20yy).

  This algorithm for determining the century is	consistent with	current
  drafts of forthcoming	X/Open UNIX specifications regarding two-digit year
  handling in various system interfaces	and commands, including	the date
  command.  This algorithm is based on the standard UNIX epoch (12:00:00 AM
  Jan 1, 1970 UTC), minus one year to account for different time zones.
  Internal UNIX	time handling is based on the number of	seconds	in this
  epoch.

  Handling of Ambiguous	Input

  If the input string is ambiguous, that is, if	the format cannot be con-
  clusively determined from the	data, the date command will issue a warning
  to stderr and	assume the mmddHHMM[[cc]yy][.ss] format.  To avoid ambiguous
  input, use one of the	three Digital formats and specify the [cc] field.

FLAGS

  -n  [Digital]	 Does not set the time globally	on all machines	in a local
      area network that	have their clocks synchronized (superuser only).

  -u  Performs operations as if	the TZ environment variable was	set to the
      string GMT0.  Otherwise, date uses the time zone indicated by the	TZ
      environment variable or the system default if that variable is not set.

ENVIRONMENT VARIABLES

  The following	environment variables affect the execution of date:

  LANG	   Provides a default value for	the internationalization variables
	   that	are unset or null. If LANG is unset or null, the correspond-
	   ing value from the default locale is	used. If any of	the interna-
	   tionalization variables contain an invalid setting, the utility
	   behaves as if none of the variables had been	defined.

  LC_ALL   If set to a non-empty string	value, overrides the values of all
	   the other internationalization variables.

  LC_CTYPE Determines the locale for the interpretation	of sequences of	bytes
	   of text data	as characters (for example, single-byte	as opposed to
	   multi-byte characters in arguments).

  LC_MESSAGES
	   Determines the locale for the format	and contents of	diagnostic
	   messages written to standard	error.

  LC_TIME  Determines the format of the	date and time strings written by
	   date.

  NLSPATH  Determines the location of message catalogues for the processing
	   of LC_MESSAGES.

  TZ	   Determines the timezone in which the	time and date are written.
	   unless the -u flag is specified.  If	the TZ variable	is not set
	   and the -u flag is not specified, a system default time zone	is
	   used.

EXAMPLES

   1.  To display current date and time, enter:
	    date


       Depending on your current locale, the output might look like one	of
       the following:
	    Thu	Apr 12	13:21:30 EDT  1992

	    jeu	12 avr	17:21:30 CUT  1992

	    tor	12 apr	17:21:30 CUT  1992


       The first output	line is	for an American	English	locale,	the second is
       for a French locale, and	the third is for a Danish locale.

   2.  To set the date and time, enter:
	    date  02171425.45


       This sets the date and time to 14:25:45 (45 seconds after 2:25 p.m.)
       February	17 of the current year.

   3.  To display the date and time in a specified format, enter:
	    date  +"%r	%d  %h	%y  (%a)"


       This displays the date (assume current year is 1993) shown in Example
       2 as:
	    02:25:03  PM  17  Feb  93  (Fri)


  Do not set the date in multi-user mode.

  Year 2000 Examples

  To set the date to 09:34:00 AM Jan 7,	2000:

   1.  Using the mmddHHMM[[cc]yy][.ss] Digital format:
	    date 010709342000
	    date 0107093400.00
	    date 010709342000.00


   2.  Using the [[cc]yy]mmddHHMM[.ss] Digital format:
	    date 0001070934
	    date 200001070934
	    date 200001070934.00


   3.  Using the mmddHHMM[.ss[[cc]yy]] Digital format:
	    date 01070934.0000
	    date 01070934.002000


   4.  Using the mmddHHMM[yy] XPG4-UNIX	format:
	    date 0107093400


   5.  An example of ambiguous input:
	    date 0101010000


       This input could	be recognized as one of	the following formats:

       mmddHHMM[[cc]yy][.ss]   meaning 01:00:00	AM Jan 1, 2000

       [[cc]yy]mmddHHMM[.ss]   meaning 12:00:00	AM Jan 1, 2001

       In this case, the date command will display a warning and assume	the
       mmddHHMM[[cc]yy][.ss] format, setting the date to 01:00:00 AM Jan 1,
       2000.

RELATED	INFORMATION

  Functions:  gettimeofday(2), ctime(3), getclock(3), setclock(3)

  Standards:  standards(5)

  Documents: Command and Shell User's Guide
9050.2NETRIX::"[email protected]"Ann MajeskeThu Mar 06 1997 11:0911
Some year 2000 functionality was added in Digital UNIX V4.0a.  This 
functionality is also available for some previous versions as a patch.
But, complete year 2000 functionality will not be available until a version 
of Digital UNIX that will be released at the end of this calendar year (I
don't
know what the official version number will be).   Some of the functionality
in that version may be made available as patches for previous versions
as well, but I wouldn't expect those patches until the same time frame
(end of the calendar year).  See notes 4628 and 481.

[Posted by WWW Notes gateway]
9050.3can't get 29-FEB-2000PMESD::FRASERFri Apr 04 1997 15:129
    
    
    Help!  I can't set date to 29-FEB-2000!  While you can set it to
    28-FEB-2000, and let the clock roll-over to Feb 29th, the year 2000 is
    a leap year,  and as such should accept input of Feb 29th.  This is
    confirmed on both UNIX 3.2G and 4.0B.  Will this be fixed in the 
    Y2K compliant version?
    
    Don
9050.4Include century; fix comingQUARRY::reevesJon Reeves, UNIX compiler groupFri Apr 04 1997 16:403
Are you explicitly including the century?

In any case, I see there's a fix in date(1) that should be in 4.0C.