; Converts mm/dd/yyyy HH:mm:ss timestamps in a file to Unix timestamps. ; Lines not recognised as dates and times in this format are skipped. ; Invalid dates, however, are not. (Feb 29 in non-leap years, etc.) ; by Cynthia of irc.rscript.org ; usage: /mmddconvert | "" ; input: ; output: .unix.txt alias mmddconvert { fopen Mmdd $$1- if ($ferr) { echo -aci2 info * Could not open $1- for reading: error $ferr $+ . return } fopen -o Unix $qt($noqt($1-) $+ .unix.txt) if ($ferr) { echo -aci2 info * Could not open $1- $+ .unix.txt for writing: error $ferr $+ . fclose Mmdd return } var %end $false while (!%end) { var %line $fread(Mmdd), %end $feof if ($regex(%line, /^(\d{2})\/(\d{2})\/(\d{4})\x20(\d{2}:\d{2}:\d{2})$/)) { %line = $ctime($+($regml(3), -, $regml(1), -, $regml(2)) $regml(4)) } fwrite -n Unix %line } fclose Mmdd fclose Unix }