Script to Generate Concurrent Times

Brahmanathaswami brahma at hindu.org
Sat Jan 17 01:29:53 EST 2015


I implemented my little algorithm... it works fine with a combo of nix 
TZ look ups + LC's native convert tools
pretty straight forward. Thanks Devin!  Do nix TZ times shift for the 
Daily Light Savings times when that goes on and off in various zones?

see:

http://dev.himalayanacademy.com/tests/dates.lc

######## CONVERT FUTURE TIME TO CONCURRENT FUTURE TIMES ##############
# Generate a list of concurrent dates and times in other countries and 
cities
# for a declared future Hawaii (HST;  UTC1000) date and time


put url "file:/home/devhap/public_html/tests/zones.txt" into tTargetCities

#  Next webinar: 1:30PM in Hawaii on February 15
put "Thu, 15 Feb 2015 13:30:00 -1000"  into tNextWebinarInHawaii

convert tNextWebinarInHawaii to seconds

# get the current time in Hawaii

put "America/Honolulu" into $TZ
put shell("date -R") into tCurrentTimeInHawaii
# the -R flag fetches the RSA
convert tCurrentTimeInHawaii to seconds

# substract current from future and get the time until next webinar 
increment

put (tNextWebinarInHawaii - tCurrentTimeInHawaii) into tFutureIncrement

# get a list of times now for several cities

repeat for each line x in tTargetCities
         put x into $TZ
         put shell("date -R") into tDTstring
         # add the increment
         convert tDTstring to seconds
         put (tDtstring + tFutureIncrement) into tFutureDTstring
        # back to human readable:
         convert tFutureDTstring to internet date
         put x & ": " & tFutureDTstring & "<br />" after tTimeInOtherCities
end repeat





Peter Haworth wrote:
> If, by chance, an SQLite database is involved in your application, its
> strftime() function has a lot of very powerful date adjustment/conversion
> tools which might help.
>
> Even without an SQLite database in an application, I sometimes create an in
> memory database just so I can issue SELECT statements to calculate dates
> and times.




More information about the use-livecode mailing list