Olin Shivers <shivers@lambda.ai.mit.edu> writes:
| I'd like to see how you convert "9/29/61" dates to "September 29, 1961"
| strings in tcl or Perl...
| ;;; "9/29/61" -> "Sep 29, 1961" date conversion.
| (regexp-substitute/global #f "([0-9]+)/([0-9]+)/([0-9]+)" ; mm/dd/yy
| s ; Source string
|
| 'pre
| ;; Sleazy converter -- ignores "year 2000" issue, and blows up if
| ;; month is out of range.
| (lambda (m)
| (let ((mon (vector-ref '#("Jan" "Feb" "Mar" "Apr" "May" "Jun"
| "Jul" "Aug" "Sep" "Oct" "Nov" "Dec")
| (- (string->number (match:substring m 1)) 1)))
| (day (match:substring m 2))
| (year (match:substring m 3)))
| (string-append mon " " day ", 19" year)))
| 'post)
It's easy in perl:
s{(\d+)/(\d+)/(\d+)}{
(Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec)[$1-1] .
" $2, 19$3"
}gse;
In tcl I'd just link with libscsh.a and call your code.
|