All of lore.kernel.org
 help / color / mirror / Atom feed
* comparing dates
@ 2003-10-10  8:54 urgrue
  2003-10-10 10:25 ` Stefan Wimmer
  2003-10-11  5:55 ` Max Lapan
  0 siblings, 2 replies; 5+ messages in thread
From: urgrue @ 2003-10-10  8:54 UTC (permalink / raw)
  To: admin

anyone know an easy way to compare dates and display the difference? 
difference doesnt have to be in date format, in fact it would be even 
easier if it was just one unit, like "total diff in seconds" or 
nanoseconds or whatever, doesnt matter.

^ permalink raw reply	[flat|nested] 5+ messages in thread
* Re: comparing dates
@ 2003-10-14 18:22 gerardo juarez-mondragon
  0 siblings, 0 replies; 5+ messages in thread
From: gerardo juarez-mondragon @ 2003-10-14 18:22 UTC (permalink / raw)
  To: urgrue; +Cc: linux-admin


I found this in an old programmable calculator
library manual:

'The number of days between dates is found by
calculating the FACTOR for each date, then
finding the difference between the FACTORS.

For January and February:

FACTOR = 365 * y + d + 31 * (m - 1) +
         int((y - 1) / 4) -
         int(3 / 4 * int((y - 1) / 100 + 1))

For March through December:

FACTOR = 365 * y + d + 31 * (m - 1) -
         int(0.4 * m + 2.3) + int(y / 4) -
         int(3 / 4 * (int(y / 100) + 1) 

The day of the week is determined from the 
FACTOR for that date as follows:

dayofweek = FACTOR + int(-factor / 7) * 7

where the day is represented by a single digit 0
through 6 for Saturday through Friday'
(that is sat=0, sun=1, etc.)

I thought you might like to just have an equation
to cut and paste into your code :-)

Cheers,
Gerardo


Searching for the best free email?  Try MetaCrawler Mail, from the #1 metasearch service on the Web, http://www.metacrawler.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2003-10-14 18:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-10  8:54 comparing dates urgrue
2003-10-10 10:25 ` Stefan Wimmer
2003-10-11 23:03   ` Chuck Campbell
2003-10-11  5:55 ` Max Lapan
2003-10-14 18:22 gerardo juarez-mondragon

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.