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-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
  1 sibling, 1 reply; 5+ messages in thread
From: Stefan Wimmer @ 2003-10-10 10:25 UTC (permalink / raw)
  To: admin

* urgrue <urgrue@tumsan.fi> wrote on 10/Oct/2003 - 11:54:08 :
> 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.

If you are comfortable with Perl you could use Date::Calc

  http://search.cpan.org/~stbey/Date-Calc-5.3/Calc.pod

It does a great job with everything involving dates ...

Greetz
Stefan 

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

* Re: comparing dates
  2003-10-10  8:54 comparing dates urgrue
  2003-10-10 10:25 ` Stefan Wimmer
@ 2003-10-11  5:55 ` Max Lapan
  1 sibling, 0 replies; 5+ messages in thread
From: Max Lapan @ 2003-10-11  5:55 UTC (permalink / raw)
  To: urgrue; +Cc: admin

urgrue <urgrue@tumsan.fi> writes:

> 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.

see options -d and %s in date's man page

-- 
Never trust anybody whose arm is bigger than your leg.

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

* Re: comparing dates
  2003-10-10 10:25 ` Stefan Wimmer
@ 2003-10-11 23:03   ` Chuck Campbell
  0 siblings, 0 replies; 5+ messages in thread
From: Chuck Campbell @ 2003-10-11 23:03 UTC (permalink / raw)
  To: admin

On Fri, Oct 10, 2003 at 12:25:21PM +0200, Stefan Wimmer wrote:
> * urgrue <urgrue@tumsan.fi> wrote on 10/Oct/2003 - 11:54:08 :
> > 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.


Sys admin published an article on date handling via shell, perl (and some
other option) recently.  All the code they discussed is available on their
site.  You would have to search for it, as I don't have the url handy.

Google for SysAdmin

-chuck


-- 
ACCEL Services, Inc.| Specialists in Gravity, Magnetics |  1(713)993-0671 ph.
 2401 Fountain View |   and Integrated Interpretation   |  1(713)993-0608 fax
     Suite 320      |                                   |
 Houston, TX, 77057 |          Chuck Campbell           | campbell@accelinc.com
                    |  President & Senior Geoscientist  |

     "Integration means more than having all the maps at the same scale!"

^ 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.