Solved

"$date" in year 2000 flaw?

Posted on 2000-03-26
5
277 Views
Last Modified: 2010-04-20
The command "date" states that when setting the time and date that the order is Month,Day, Hour, Minute, Year.
[MMdd]hhmm[yy]?
There is only two entries for the year "yy" . This means that unix would not be Y2K compliant.
     Can someone tell me if the "date" command has evolutionized to y2k or not. I am deeply greatful for any response. Thank you.

                        tionik@aol.com
0
Comment
Question by:tionik
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 40

Expert Comment

by:jlevie
ID: 2659569
While it might not seem so on casual examination, Unix does know that 00 as the year in the "date" command must be 2000. And it knows this because the epoc for Unix is something like 1972 or so. There simply weren't any Unix boxes earlier than that, therefore 00 has to be 2000, it can't possibly be 1900. Now what would happen in 3000... I think we've got enough to time to solve that one.
0
 

Author Comment

by:tionik
ID: 2662116
This is a question I know ,and I am quizing you on it.
0
 
LVL 1

Accepted Solution

by:
philiph_elvis earned 75 total points
ID: 2662342
Unix systems keep time internally as the number of seconds since the "epoch", which is defined as 00:00:00, Jan 1, 1970.

This number is stored as a 32 bit integer, thus it will overflow some time in 2038.

The "date" command converts from this internal representation to some other format.  By default, "date" shows the years as "YY".  This is just a display function - you could use "date +%Y" instead and see the full four digit year instead - 2000.

Thus no matter how the date command works, the internal representation of time is y2k-compliant.

The gnu version on date on my linux box takes either 2 or 4 digit years when setting the time.  It appears that if you only give it only two year numbers, the range can be between 00 and 59, however that seems to be ingored on my system - the year isn't actually changed.  you have to specify the full 4 digit year to actually change the year.  I think the two digit year is accepted and ignored for compatibility with other versions of date.

So on linux, use four digit numbers when setting the date.
0
 
LVL 40

Expert Comment

by:jlevie
ID: 2662484
Okay let me try one more time. The date command is Y2K okay as Unix will not allow the date to be set earlier than the Unix epoc, which is 00:00 UCT 1 Jan 1970 on most maintream implementations. This means that years between 72 and 99 are dates in the range 1972-1999, years above 00 will be 2000 & greater. At least until 2038 at the moment on most implementations.

I don't have a large sample to play with but each Unix that do have access to returns "Bad date format" for years prior to the epoc or greater than 38 (2038). And the reason for this is that Unix doesn't keep the "date" internally in the form you might think. It stores the date as the number of tics or seconds since the epoc. This removes any Y2K concerns from the internal timekeeping (Unix was Y2K okay from the git-go), user applications may not have been. At present the only date we have to worry about will be 2038 or there abouts, which would be when the storage for clock ticks (typically a long) will overflow.

Oh yeah, I don't know what Unix you are on, but Solaris, Linux, & Irix optionally allow the specification of the century, Something like: "date [OPTION] [MMDDhhmm[[CC]YY][.ss]] "
0
 

Author Comment

by:tionik
ID: 2671837
Goog Job.
GNU "$date" is now in [mm,dd,tttt,cc,yy].
Focus on    ^
"cc" is for a two digit entry for the century. Such as (19)99 or (20)00.




                    Extremely well done!

             
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question