Please put aside the different formatting. What i would like to highlight is that date reports time in BST whereas DateTime->now reports time in UTC.
Given perl's DWIM ideology, should now actually report BST for my case?
I realise i can do:
perl -MDateTime -e "print DateTime->now(time_zone => 'local')->strftime('%c %z %Z')"
to give me what I'm looking for. My question is simply, do people think the spec/definition of the now method should be changed, or do people think it should stay as it is?
If it should stay as it is. Do people think it might be worth adding a warning in the documentation for inexperienced users so they realise what they are getting? Or do people feel the documentation is sufficiently clear already?
I'm raising these questions because i didn't expect now the behave like this, and so used it incorrectly until my test rig caught my mistake.
Testing is good.
We've had conversations about this several times on this list .. search the archive for '"localtime" DateTime objects' just a couple of weeks ago .. normally I'm the one who asks that the behaviour be changed :)
The problem appears to be that we don't always know the 'local' time zone. Some OSes store a compatible zone somewhere and we use that when you ask for local. Some OSes (Windows comes to mind) doesn't. Thus we can't return local.
And we definitely can't return local only when we have it because that will break stuff all over the place. The only thing we're sure of is UTC - so that's what you get when you call now() without a time zone.
As for the docs, yes some clarity would be good. The docs for new() say that the default time zone is floating. However the docs for now() don't say anything outright, just that it uses perl's time() function (and only by inference do we realise that time() is returning UTC).
I'd like to ask that the docs for new() and now() have the following patch applied so I (and others) don't have to ask the same thing again. I've moved things around to talk about defaults first as I believe that that would be the first thing people need to read. It used to appear in the middle of the validation information. I personally would skim over all the validation documentation unless I had problems.
I've also changed the now() documentation to specifically state that the default will be UTC because perl's time function returns UTC.
Cheers! Rick
--
--------------------------------------------------------
There are 10 kinds of people:
those that understand binary, and those that don't.
--------------------------------------------------------
The day Microsoft makes something that doesn't suck
is the day they start selling vacuum cleaners
--------------------------------------------------------
"Write a wise proverb and your name will live forever."
-- Anonymous
--------------------------------------------------------
DateTime.diff
Description: Binary data
