Hacker News new | ask | show | jobs
by ralferoo 661 days ago
I came across a reasonable amount of perl code that happily formatted the year 2000 as 19100. The functions that converted from seconds-since-1970 to a "human readable" parts returned a year relative to 1900. Most people would format using sprintf("%d/%d/%d",$d,$m+1,$y+1900) but some code I inherited instead used sprintf("%d/%d/19%d",$d,$m+1,$y). I never did figure out if it was due to stupidity or malice.
2 comments

I kept seeing this behaviour on some websites in to the late 00s and possibly even in to the early 10s, your comment mede me realise I haven't seen it recently though :(
A big part of that problem was Javascript's terrible Date API, which was practically a carbon copy of the (equally terrible) java.util.Date. For no good reason, its Date.getYear() method returned the number of years since 1900.
I remember booting up an emulated CADR for the first time and, after entering the date as something, something, 2008, was startled for the status bar to read a year of 19108.

I also did my quick Lisp sanity test of saying (* 4 3) and expecting 12 -- but I got 14 instead. It was then that I learned the CADR speaks octal by default.