Browse Prior Art Database

# A method to easily convert dates into microseconds since 1900 and viceversa.

IP.com Disclosure Number: IPCOM000033273D
Original Publication Date: 2004-Dec-03
Included in the Prior Art Database: 2004-Dec-03
Document File: 1 page(s) / 39K

IBM

## Abstract

This article describes a fast algorithm to implement unix standard functions that converts Calendar dates into seconds and viceversa, with a 64-bit technology.

This text was extracted from a PDF file.
This is the abbreviated version, containing approximately 90% of the total text.

Page 1 of 1

A method to easily convert dates into microseconds since 1900 and viceversa.

The unix standard functions that convert Calendar date to seconds and viceversa are implemented using 32-bit technology so they have limitation from 1970 to 2038 dates.

Two sofware modules that have been designed and developed to perform conversion using 64-bit values so they can support at least from 1900 to 9999 dates.

Moreover these modules implement a fast algorithm that uses a conversion table. This table is made of 61 rows each containing a structure. Each structure has the absolute century not leap year and a 64-bit integer containing the number of microseconds passed from 1900 January 1st at 00:00:00 , to that year January 1st 00:00:00. Century not leap years are actually the only year divisible by 4 that are not leap. So between two positions in the table one year every 4 is surely leap. The usage of that table ensures a very fast algorithm.

The following is an example of conversion of a number of microseconds from 1900 to calendar date,

1) input microseconds are compared with those in the table until the position containing the lower and closest number of microseconds is found.

2) seconds in the position are subtracted from input.

3) above rule ensures that a simple division by constant number of microseconds included in 4 year (with a leap year) is enough to obtain the year of the output date.

4) Month , day, hour, minute, seconds, and microseconds are easily calculated starti...