On 1/28/2015 8:12 PM, Brahmanathaswami wrote:
I have to deal with a lot date/time based algorithms on CentoOS/Word
Press (and other similar frameworks) where "the Date" is usually output
liked this, with no timezone code

2000-02-17T22:13:21-05

As anyone written a script to convert this to seconds? I need to compare
such a date with the time right now in LiveCode(server) and the only way
is via seconds.

This should work:

function convertDate pDate
  put char 1 to offset("T",pDate)-1 of pDate into tDate
  put char offset("T",pDate)+1 to -4 of pDate into tTime
  put char -3 to -1 of pDate into tHrOffset
  replace "-" with slash in tDate
  set the itemdel to slash
  put item 2 to 3 of tDate & slash & item 1 of tDate into tDate
  set the itemdel to comma
  convert (tDate && tTime) to dateitems
  add tHrOffset to item 4 of it
  convert it to seconds
  return it
end convertDate

If the time zone includes minutes, you'd need to extract those and add them to the minutes item of the dateitems, just before or after the hrOffset is added.

--
Jacqueline Landman Gay         |     jac...@hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com

_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to