Date Troubles

Michael D Mays michael.rr at mdmays.com
Tue Jan 18 09:34:55 EST 2005


The date formats only works over a short period of time, about 2^32 
seconds (4 byte word). That is about 1934 to 2035. If you are using 
dates outside of that region then you need to work with dateItems and 
seconds. I think dateItems gives you the largest time span. To do this 
you have to convert your date to a dateItem with your own handler, not 
the convert function:

put "7/18/1868" into theDate
put myDateItemHandler(theDate) into theDate

function myDateItemHandler theDate
   get the itemDelimiter -- this get/set may not be needed
   set the itemDelimiter to "/"
   put item 1 of theDate into theMonth
   put item 2 of theDate into theDay
   put item 3 of theDate into theYear
   set the itemDelimiter to it-- this get/set may not be needed
   return theYear&comma&theMonth&comma&theDay&comma&comma&comma&comma
end myDateItemHandler

You can convert this dateItem to seconds and do your calculations. If 
you want to return a date convert your seconds to dateItems and write a 
handler which creates your desired date format.

Michael

On Jan 17, 2005, at 6:58 PM, Sarah Reichelt wrote:
>> What do I need to do to make the following work right? To get the 
>> centuries
>> right?
>>
>> put "7/18/1868" into temp
>>   put temp into  fld 1
>>   convert temp to seconds
>>   put "  --  "&temp after fld 1
>>   convert temp to long date
>>   put "  --  "&temp after  fld 1
>>
> Hi Nelson,
>
> The only way I could get it to work was to use Julian dates. if you go 
> to my web page, you will see a DateTime library: "DateTime.rev.gz", 
> which includes functions for translating dates to & from Julian 
> format, originally written by Mark Weider.
>
> Cheers,
> Sarah
> sarahr at genesearch.com.au
> http://www.troz.net/Rev/



More information about the use-livecode mailing list