Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DateTime's time zone should be normalized before saving #100

Open
paranoiq opened this issue Jul 13, 2013 · 4 comments
Open

DateTime's time zone should be normalized before saving #100

paranoiq opened this issue Jul 13, 2013 · 4 comments

Comments

@paranoiq
Copy link
Contributor

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: nette/nette#1168)

@milo
Copy link
Collaborator

milo commented Jul 14, 2013

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.

@paranoiq
Copy link
Contributor Author

paranoiq commented Aug 2, 2013

@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

@milo
Copy link
Collaborator

milo commented Aug 2, 2013

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.

@paranoiq
Copy link
Contributor Author

paranoiq commented Aug 2, 2013

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants