After chasing down an obscure date change bug, how not to do date handling in DCL, and how to do it correctly.
First, how not to do it:
$ today = f$cvtime ("")
$! [snip]
$ tomorrow = f$cvtime ("tomorrow")
Well, what's wrong with that, you ask? What if midnight occurs between the two calls to the f$cvtime lexical? Reading the command procedure I found this in, the programmer's obvious intention was to have variables today and tomorrow reflect two contiguous days, but he didn't plan on the command procedure running near midnight. The bug was triggered when today was 2010-04-03 and tomorrow was 2010-04-05.
Here's how to do it correctly:
$ now = f$time ()
$ today = f$cvtime (now)
$! [snip]
$ tomorrow = f$cvtime ("''now'+1-")
Posted at April 13, 2010 3:31 PM
Comments are closed