All of lore.kernel.org
 help / color / mirror / Atom feed
From: "gerardo juarez-mondragon" <gjuarezmondragon@metacrawler.com>
To: urgrue@tumsan.fi
Cc: linux-admin@vger.kernel.org
Subject: Re: comparing dates
Date: Tue, 14 Oct 2003 13:22:43 -0500	[thread overview]
Message-ID: <BEA94E0C5D7C9F742B1AF2BF0F3F249D@gjuarezmondragon.metacrawler.com> (raw)


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

             reply	other threads:[~2003-10-14 18:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-14 18:22 gerardo juarez-mondragon [this message]
  -- strict thread matches above, loose matches on Subject: below --
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BEA94E0C5D7C9F742B1AF2BF0F3F249D@gjuarezmondragon.metacrawler.com \
    --to=gjuarezmondragon@metacrawler.com \
    --cc=linux-admin@vger.kernel.org \
    --cc=urgrue@tumsan.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.