Page 1 of 1
coding help
Posted: 22 Dec 2007 22:06
by tigerface
Hi,
I need a bit of help setting the introduction date of vehicles, I just can't get it right!
On the wiki it says 1-1-1920 is 701265 days from year 0. well thats 701280 days from year 0...?
While I'm here.. Hex is not a strong point. 701265 is 51 B3 0A 00? Is that in little-endian order?
Sorry for all my nooby questions..
Jr.
Re: coding help
Posted: 22 Dec 2007 22:12
by Rubidium
thanet-bomber wrote:On the wiki it says 1-1-1920 is 701265 days from year 0. well thats 701280 days from year 0...?
A year usually consists of 365 days, except for leap years. You assume that there is a leap year every four year (701280/1920 = 365.25). This is 'wrong' because when the year is dividable by 100 it is non a leap year (-19), unless it is dividable by 400 because then it is a leap year (+4).
Re: coding help
Posted: 23 Dec 2007 00:57
by tigerface
wow I never knew that! learn something new every day. cheers for your help!
Re: coding help
Posted: 23 Dec 2007 04:00
by DaleStan
thanet-bomber wrote:Hex is not a strong point. 701265 is 51 B3 0A 00? Is that in little-endian order?
Then don't use it. "\d701265" will encode that number in a dword, exactly as you want, with no hassles about endianness. (But don't use that either.) If you want to know how it came out on the other end, just encode and decode, and read the decoded sprite. (And, yes, it is LE.)
The proper way to encode January 1, 1920, for the long-date properties, is one of "\d1/1/1920", "\d1-1-1920", "\d1920/1/1", or "\d1920-1-1". This is either YMD or DMY order. No middle-endian silliness is supported, even if I[0] do live in a country that chooses to use that format.
[0] I wrote this part of the spec, hence why my preferences have bearing here.