CLF = WTF?

Ken Ray kray at sonsothunder.com
Sat Mar 7 15:54:49 EST 2009


> 2. Right now I'm parsing the CLF date and reformatting it into "internet
> date" using about a dozen lines of code, and maybe it could be
> simplified a bit more but what I'd ideally like is the efficiency of a
> one-liner.  Anyone here know of a what to alter CLF dates into a form
> that will survive Rev's "convert" command in one or two lines?

How about three (of course there's no error trapping):

put "10/Oct/2000:13:55:36 -0700" into tDate  -- to start us off

get matchText(tDate,"(.*?)/(.*?)/(.*?):(.*?)$",tDay,tMonth,tYear,tRest)
convert (tMonth && tDay && tYear) to abbr date
put (item 1 of it) & "," && tDay && tMonth && tYear && tRest



To do it right, you'd want to do something like this:

function FixDate pDate
  if matchText(tDate,"(.*?)/(.*?)/(.*?):(.*?)$",tDay,tMonth,tYear,tRest)
then
    convert (tMonth && tDay && tYear) to abbr date
    if it <> "invalid date" then
      return (item 1 of it) & "," && tDay && tMonth && tYear && tRest
    else
      return "invalid date"
    end if
  else
    return "invalid format"
  end if
end FixDate

Ken Ray
Sons of Thunder Software, Inc.
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/





More information about the use-livecode mailing list