Open paranoiq opened 11 years ago
What about %d
and %t
do the normalization,
and modifiers %dz
and %tz
wouldn't, plus add timezone value.
Next point is, how to get the server timezone value. I don't use the MySQL, but afaik, value DEFAULT
can be returned. From my point of view, normalization should be done only if configured (I mean in PHP application), or it should be setable on Connection.
@milo: i do no think we need a "yes pleas, shoot me in my leg" modifier
getting the timezone is the tricky part. timezone is set by Dibi on connection start, but a "+02:00" format is also enabled* and currently used as default if no timezone is given
*) allowing this could be considered as another bug, because setting offset in config file does not consider DST time shifts over the year. but it should be bacward compatible, i guess...
my current sollution for Dibi is here: https://gist.github.com/paranoiq/6021606
i do no think we need a "yes pleas, shoot me in my leg" modifier
Your solution is good for DBs without timezoned type. But what about e.g. PostgreSQL? Imagine the query, where created
column is capable to save the timezone:
$dibi->query('INSERT INTO tab (created) VALUES (%d)');
I think, instead of %d
shoud be %dz
explicitly used. I don't see any way how to do the detection.
Your kind of solution for DateTime normalization is good and it is not in conflict in proposed %dz
and %tz
modifiers.
allowing this could be considered as another bug
Agree. I parcipated in the discussion on Nette FW issue when it was removed.
you are right. i missunderstood your first comment. in that case the %dz
/%tz
makes sense. it should be driver specific and should throw an error on database which does not support it (or fallback to %d
/%t
?)
I parcipated in the discussion on Nette FW issue when it was removed.
what issue do you mean?
if a DateTime has different time zone, it shold be normalized to the time zone of server
there may be databases, which are capable of saving a datetime with timezone, so i am not sure yet, if the normalization shold occur in DibiFormater or in a Driver
(see also: https://github.com/nette/nette/issues/1168)