Re: getting the date
Re: getting the date
- Subject: Re: getting the date
- From: Graff <email@hidden>
- Date: Tue, 30 Dec 2003 23:40:14 -0500
On Dec 30, 2003, at 10:49 PM, Walter Ian Kaye wrote:
At 06:28p -0500 12/30/2003, Graff didst inscribe upon an electronic
papyrus:
((b - theDate) div -2500000 + 1 )
Which takes the difference (in seconds) between the current date and
and the the same day in January, divides that by 289 days (in
seconds) and adds a month. This gives you the current month,
roughly. This will probably work fine but I'd worry about it being
correct under all circumstances.
OK, but then what makes 289 days so magical?
Sorry, my bad. I must have forgotten a decimal point, that should be
approximately 28.9 days. Approximately the average length of a month.
Basically the theory is if you divide a number from 0 to 29999999 by
2500000 and cut off the decimal part you will get a number from 0 to
11. Add one to that and it is from 1 to 12, corresponding to the
number of month. The only thing is that there are up to approximately
31622400 seconds in a year. However, this technique is saved by the
fact that it loses one month worth of seconds since it counts from 1/20
to 12/20 (for example) instead of 1/1 to 12/20. Counting from 1/20 to
12/20 is under 29000000 seconds, a number that works.
It is a rough method but it does work. I would prefer to use a clearer
and more precise method but I can't argue with the results of this
script. If you want to convert a date quickly and you don't care if
people easily understand how it works then this script is for you.
- Ken
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.