diffdays

peter.fink at tiscali.ch peter.fink at tiscali.ch
Fri Jul 19 08:50:03 EDT 2002


>
>Could you share these 20 lines of code? I don't have a clue where to start.
>
>Terry
>
>


function DateToSeconds aDate
  -- convert aDate = mm/dd/yy or mm/dd/yyyy into seconds since 1/1/1970

  set the itemDelimiter to "/"
  put item 1 of aDate into mm
  put item 2 of aDate into dd
  put item 3 of aDate into yyyy
  if the length of item 3 of aDate = 2 then
    if yyyy<= the centuryCutoff then add 2000 to yyyy
    else add 1900 to yyyy
  end if
  set the itemDelimiter to comma
  put "0,31,59,90,120,151,181,212,243,273,304,334" into LL
  put yyyy into y
  put yyyy*365 + trunc((y+3)/4) - trunc((y+99)/100) + trunc((y+399)/400)
into days
  add ((item mm of LL) + dd-1) to days
  if mm>2 then
    if yyyy mod 4=0 then if yyyy mod 100<>0 or yyyy mod 400=0 then add 1
to days
  end if
  subtract 719528 from days
  put days*86400 into secondes
  return secondes
end DateToSeconds









More information about the use-livecode mailing list