|
-
Jun 17th, 2001, 06:00 PM
#1
Thread Starter
transcendental analytic
Date algoritm
maybe this isn't the right forum for this, but it's my favourite forum so i decided to post here 
I need an algoritm to express a date format stored as a 32bit integer. In fact i need to express a date according to any planet with or without at least one moon. If there's no moons, month is omited and year and day is expressed. The time for the 32 bit integer is absolute. Currently i only know how to get year:
year= Time/Sunrot;Time%=Sunrot;
day=Time/Planetrot;
here's where i get stuck, the Planet rotates absolute to Time, but since the first day has to start with the first whole day I don't know where the day changes as original Time is erased. That would be nothing compared to the next problem, how do i put in the days on leapyears and how should i put in or remove extra leapyears?
Another qwestion, is there a reason to why each month is different length (on earth)?
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jun 17th, 2001, 07:36 PM
#2
Good Ol' Platypus
It's because the gregorian calender is screwed big time.
Actually, it wouldnt fit with only 30 day months and only 31 day months so they decided on a mixture of the two (that and 28 day months, 29 if leap year)
A year is 365.25 (approx.) days.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Jun 17th, 2001, 08:17 PM
#3
Thread Starter
transcendental analytic
thanks, i was expecting something like that, but i still need a screwed up model of counting months, based on days, shouldn't be a problem except very annoying.
Anyway i worked out the leapyear problem by drawing some diagrams and banging my head against the wall a couple of times.
Code:
Year=Time/Sun;
X=Time%Planet; //Time Since Midnight
Day=((Time%=Sun)+Planet-X)/Planet; //Time gets relative to NewYear, Convert to day after adding the rest of the day.
if (!Day){ //Day belongs to last year
Day=Sun/Planet+((X-Time)<(Sun%Planet)); //Last day of last year + possible leapyear, which happens when the gap between
Year--; //Last day and current year is smaller than the gap between first year's last day
} //and Second year.
the whole thing got clear when i realized the first gap on a year shouldn't be smaller than the gap for the absolute year and last day. I'm still wondering if i should have Years starting at 0 or 1 since Day starts on 1.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jun 17th, 2001, 08:33 PM
#4
Thread Starter
transcendental analytic
BTW
How many times (exactly) does the moon rotate around earth per year? that is how long does it take for moon to make a revolution around earth. If it's not 1/12 a year then what?
In case moons don't have a tendency to make integer amount of revolutions per year (pardon my ignorance in astronomy) i'm running into another problem, should i include an option for having month relative to year as day is and then have day relative to month? (i want to be a bit realistic extrapolating alien intelligence)
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jun 18th, 2001, 08:40 PM
#5
Addicted Member
-
Jun 19th, 2001, 04:02 PM
#6
Thread Starter
transcendental analytic
Thanks, hmm 13.36 months i didn't know that
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jun 21st, 2001, 11:26 AM
#7
-
Jun 22nd, 2001, 12:54 PM
#8
Thread Starter
transcendental analytic
Not too hard to simulate a screwed up calendar, but i'm also planning on serious ones
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|