Current Issue


Table of contents

CD-ROM

Sys Admin and The Perl Journal CD-ROM version 12.0

Version 12.0 delivers every issue of Sys Admin from 1992 through 2006 and every
issue of The Perl Journal from 1996-2002 in one convenient CD-ROM!

Order now!

Sys Admin Magazine > Archives > 1999 > 9901

Linux and the Y2K Bug

Robert Kiesling

Listing 1 | Listing 2

Linux, like other POSIX-compliant operating systems, provides facilities for coping with the Y2K bug, and software written properly for Linux should be able to cope with the end of the millennium. As a systems administrator, however, you may want to test both your Linux systems and any applications running on them for date compliance.

This article describes the time keeping functions that are available in the Linux C libraries, Version 5. The GNU glib2 libraries, which are still in the early stages of development, will provide similar functionality and compliance with time keeping standards. I also explore how you might go about testing Linux-based applications for date compliance.

Linux Time

Linux keeps track of the time using the 32-bit time_t type that maintains the count of UTC calendar time, which is the number of seconds since January 1, 1970. It is declared in time.h as the following:

typedef long time_t;

The standard UNIX utilities (or the free software versions distributed by the GNU project) that have been ported to Linux, support this data type. Assuming that the hardware clock handles the dates in the next century correctly, time keeping should be correct until the year 2038, when the 32-bit time_t counter will overflow. Solving what may become known as the Y2038K bug is beyond the scope of this article, however.

The Linux libraries include the following functions to provide time and date information.

time()    /* Returns the value of time_t in seconds.        */
ctime()   /* Returns ASCII formatted output from time_t.    */
stime()   /* Set the date and time using UTC calendar time. */

Functions related to ctime(), such as asctime(), gmtime(), localtime(), and mktime(), use the value stored in time_t and return hours, minutes, seconds, day, date, month, and year in either data structure tm, or in ASCII format.<>




MarketPlace

Download Award-Winning Service Desk software, Free
Try Numara FootPrints 9, The ITSM software that Delivers Real Value, Flexibility and Results.

Instant Answers to Your IT & Business Questions
Sign Up & Get Full Access To The Definitive Online Book Collection With SkillSoft's Books24x7�.

BugSplat - Automatic Crash Analysis
Fast online exception analysis. Capture customer crash data online.

Visit Dell� Small and Medium Business Online Store
One Stop to Buy All Your Business IT Solutions. Browse Through Dell's Best Deals Online Now!

Wanna see your ad here?