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
Add date formatting and from/to unix timestamp conversion #763
Conversation
Hello, thank you for creating this pull request. I have automatically opened an issue http://www.doctrine-project.org/jira/browse/DBAL-1101 We use Jira to track the state of pull requests and the versions they got |
@andig what is the exact use-case? |
Yeah a use-case would be good. Also looking at this it seems we would need another abstraction level for the date format which requires us to implement a parser to be able to convert the DBAL date format into the database specific format. Not sure if that is worth the effort for 2.x... |
At http://www.volkszaehler.org we've developed a smart meter app. Millions of meter readings are stored with their timestamp in ms since 1970- unix timestamps. For analytical purposes the middleware has abilities to retrieve readings grouped by day, month, year etc which requires unix timestamp <-> date conversions as well as date arithmetics. While we've originally only supported MySQL, large but not all parts of the application are already running on SQlite and PostgreSQL. Looking at what's missing and how to do this in the most portable way I've found the biggest gaps in the unix timestamp and date formatting functions. The missing date arithmetics have already been added in 2.5.0 (though unfortunately |
@andig this sounds like a very custom use-case, whereas DBAL is a common abstraction layer. What would other users do with such a functionality, and why can't the |
I don't know how you classify custom and non-custom use cases, but unix timestamp conversion is a recurring problem on various platforms (http://stackoverflow.com/questions/3693076/unix-timestamp-in-sqlite, http://stackoverflow.com/questions/20124862/timestamp-on-postgresql-to-unix-timestamp). MySQL has built-in functions for this purpose, other DBs do it via more general date formatting functions. What I would- on second though- agree with is that it might not be the right way to approach this problem by generalizing the MySQL solution of specific functions for that purpose. |
One thing that you might consider is that we don't consider timestamps as supported (because of how much they differ across platforms) |
I wasn't aware of that. Thanks for bearing with me trough this discussion! I'll approach this by subclassing the relevant platforms for now and will see what 3.0 then brings. |
I'm proposing to add date formatting as well as from/to unix timestamp conversion to DBAL. If this PR is going to find resonance I'd gladly add implementations for SQlite and MySQL.
Please let me know if this is something worth to pursue.