Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Challenge: Compute number of days between two dates.
#11
I considered adding a check for the 10-day drop (Oct. 4 to 15, in the year 1582) but this might have been going overboard Wink

*peace*

Meg.
Reply
#12
Quote:I considered adding a check for the 10-day drop (Oct. 4 to 15, in the year 1582) but this might have been going overboard Wink

*peace*

Meg.

Ahem.... maybe. But if you could that proggie would be no. 1 in QBasic for that (do you want to be the authority on something? Wink)
Reply
#13
Quote:I considered adding a check for the 10-day drop (Oct. 4 to 15, in the year 1582) but this might have been going overboard Wink

*peace*

Meg.

Are you saying that days from Oct.5 to Oct 14, in 1582, didn't happen? Tongue
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#14
According to the Gregorian calendar, the day after October 4th, 1582 was October 15th, 1582 to compensate for the Year actually being slightly less than 365.25 days long (which is why now leap years DO occur on 1600, 2000, etc. but NOT on 1700, 1800, etc. They did before this, and it was throwing off the calendar little by little.) So they skipped 10 days in this year to line everything back up. Well, different countries adopting the Gregorian calendars shifted in different years, but the original Gregorian calendar had it in 1582.

:lol:

*peace*

Meg.

p.s. no, I don't know all this. I looked it up. 8)
Reply
#15
The way I always thought it was that the leap year is either skipped or extended every 128 years to adjust for the earth's funky rotation cycle. but it's pretty cool that people were smart enough to adjust dates based on the earth's rotation as early as 1582. for heretic-burning mummy drinkers they seem to have their head on straight Smile

oh, and meg: that code might be a little smaller if you converted the gregorian day to julian and just subtracted Smile
i]"I know what you're thinking. Did he fire six shots or only five? Well, to tell you the truth, in all this excitement, I've kinda lost track myself. But being as this is a .44 Magnum ... you've got to ask yourself one question: 'Do I feel lucky?' Well, do ya punk?"[/i] - Dirty Harry
Reply
#16
MEG,

All the implementatioms that I've seen do one of the following:

1) Ignore the year 1582 problem altogether, just like your code does.

2) Pick a pivot date like 1800 or newer, and figure cumulative days as starting on January 1st of that pivot date.

You are one heck of a programmer for doing that program in 1.5 hours. It would take me more than that just to analyse the problem.

However, I must comment on the one-liner for calculating the number of days in a month. Although it works, I think this piece of code it is excessively complex, almost Machiavellian.

By the way, a published six-line algorithm exists for converting a date to the number of days from year zero. It also is a bit complex.
*****
Reply
#17
yeah it prolly could be calculated a lot easier. what that line basically says is:

m = 31
if month is > 7 and odd, subtract one
if month is < 8 and even, subtract one

so it just uses weights and multiplies them by the boolean (m%>7) and (M%< 8 )

so it looks pretty complex, but it's pretty straightforward.

there prolly is a more efficient way to calculate it tho. I was just coding really fast Smile

*peace*

Meg.
Reply
#18
Again, Meg, you're something special. When I have to code something in a hurry, I code it as straightforward as possible. It really annoying to look at piece of code later and wondering what I was trying to do. Unless of course, I heavily commented it.
*****
Reply
#19
I try to comment my code, but i get really lazy about it.... Smile

p.s. thanks so much for the kind words Smile i've always respected the way you handle people on this forum. you've a knack for challenging and criticizing people in a way that's not insulting Wink And also, I like that you don't get all up in a huff if somebody criticizes you Very professional Smile

p.p.s. my brain doesn't seem to grasp the concept of "straightforward" from time to time...

*peace*

Meg.
Reply
#20
MEG, I certainly thank *you* for your kind words. You¡re a gal after me own heart. Some day I'll say that I met you on this forum, and not only were you most charming, but one of the best programmers that I ever met.
*****
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)