Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!weretis.net!feeder4.news.weretis.net!feeder1.news.weretis.net!news1.tnib.de!feed.news.tnib.de!news.tnib.de!newsfeed.in-ulm.de!not-for-mail |
|---|---|
| From | Christian Neukirchen <chneukirchen@gmail.com> |
| Newsgroups | comp.misc |
| Subject | Re: The 8-Byte Two-Step |
| Date | Tue, 23 Sep 2014 18:26:59 +0200 |
| Organization | [ posted via ] IN-Ulm |
| Lines | 39 |
| Sender | chris@juno |
| Message-ID | <87lhpawbe4.fsf@gmail.com> (permalink) |
| References | <01T8OImfoeUtayhTm1xJJ0vS@dont-email.me> <c86928Fkug2U4@mid.individual.net> <87ppeq2car.fsf@elektro.pacujo.net> <c87gfnFkjjcU1@mid.individual.net> <87d2ap2pjn.fsf@elektro.pacujo.net> |
| Mime-Version | 1.0 |
| Content-Type | text/plain |
| X-Trace | news.in-ulm.de AF9A86FC9BE6E5985520A22B97EF109C |
| In-Reply-To | <87d2ap2pjn.fsf@elektro.pacujo.net> (Marko Rauhamaa's message of "Sun, 21 Sep 2014 14:14:52 +0300") |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
| Xref | csiph.com comp.misc:5053 |
Show key headers only | View raw
Marko Rauhamaa <marko@pacujo.net> writes:
> Bob Eager <news0002@eager.cx>:
>
>> On Sun, 21 Sep 2014 00:48:44 +0300, Marko Rauhamaa wrote:
>>> def gregorian_day_count(isodate):
>>> year, month, day = map(int, isodate.split('-'))
>>> a, b = divmod(12 * year + month + 1185, 12)
>>> return int(a * 365.2425) + int(30.573 * b + 0.706) + day
>>
>> [...]
>>
>> Didn't know that one...thanks!
>
> Except, you shouldn't believe everything you read on the Internet :) --
> the above code had a bug which I noticed when I actually tested it.
>
> Here's a correction:
>
> def gregorian_day_count(isodate):
> year, month, day = map(int, isodate.split('-'))
> a, b = divmod(12 * year + month - 3, 12)
> yeardays = a * 365 + a // 4 - a // 100 + a // 400
> return yeardays + int(30.573 * b + 0.706) + day
>
> If you intend to use the code, you're well advised to test it yourself.
I found this one, which is similar in spirit but doesn't depend on
floats:
http://alcor.concordia.ca/~gpkatch/gdate-algorithm.html
function g(y,m,d)
m = (m + 9) % 12
y = y - m/10
return 365*y + y/4 - y/100 + y/400 + (m*306 + 5)/10 + ( d - 1 )
--
Christian Neukirchen <chneukirchen@gmail.com> http://chneukirchen.org
Back to comp.misc | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
The 8-Byte Two-Step Rich <rich@example.invalid> - 2014-09-20 20:41 +0000
Re: The 8-Byte Two-Step Bob Eager <news0002@eager.cx> - 2014-09-20 21:14 +0000
Re: The 8-Byte Two-Step Marko Rauhamaa <marko@pacujo.net> - 2014-09-21 00:48 +0300
Re: The 8-Byte Two-Step Bob Eager <news0002@eager.cx> - 2014-09-21 08:27 +0000
Re: The 8-Byte Two-Step Marko Rauhamaa <marko@pacujo.net> - 2014-09-21 14:14 +0300
Re: The 8-Byte Two-Step Marko Rauhamaa <marko@pacujo.net> - 2014-09-23 11:19 +0300
Re: The 8-Byte Two-Step Christian Neukirchen <chneukirchen@gmail.com> - 2014-09-23 18:26 +0200
Re: The 8-Byte Two-Step mm0fmf <none@mailinator.com> - 2014-09-21 20:45 +0100
Re: The 8-Byte Two-Step Sylvia Else <sylvia@not.at.this.address> - 2014-09-21 13:42 +1000
csiph-web