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)?