lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Tue, Jan 09, 2007 at 06:09:39PM -0200, Roberto Ierusalimschy wrote:
> > I took a quick look at the os_time function in loslib.c, and the default 
> > value for hour is 12 (noon) instead of 0 (midnight).  If you want it to 
> > be midnight, add "hour=0" to the table that you pass to os.time.
> > 
> > To Roberto or Luiz:  Is this a bug, or is it intentional?
> 
> It was intentional. It is even documented in PiL (pg. 202, 2nd edition)
> (although not in the manual). I never realized that 'date' has a different
> default. (Noon seems to be more "inside" a given date than midnight...)

That's true; but in, say, a business setting, if I ask for all events
happening between 01/08/2006 and 01/09/2006, I would want events
logged at 8:39 to track to the same date as events happening at 15:49
that afternoon, not be sliced in half by the noon hour. Of course, for
an astronomical setting, using noon as the default makes perfect
sense. I will follow the suggestion to use hour=0, as that will no
doubt be a little faster than my silly kludge of adding an offset to
the result...

Thanks!