[Newbies] Efficient date parsing

Randal L. Schwartz merlyn at stonehenge.com
Wed Apr 2 20:47:01 UTC 2008

>>>>> "stan" == stan shepherd <squeak414 at free.fr> writes:

stan> Is there a more efficient way? Is there a standard method I've missed?

One thing you should ensure is that you're not converting the same date twice.
Typical logs have thousands of entries all with the same date, and I've seen
far too many naive solutions that keep converting, over and over again,
'2008-02-15' into Feb 15 2008.  Really no point.

Implement a simple cache:

   ^dateCache at: dateString ifAbsent:
      [dateCache at: dateString put: (Date from: dateString)].

something like that.

Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn at stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

More information about the Beginners mailing list