[Bug 37831] New: Timezone ignored when passing rfc3339 formatted date
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37831 Bug ID: 37831 Summary: Timezone ignored when passing rfc3339 formatted date Change sponsored?: --- Product: Koha Version: unspecified Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: REST API Assignee: koha-bugs@lists.koha-community.org Reporter: jonathan.druart@gmail.com QA Contact: testopia@bugs.koha-community.org CC: tomascohen@gmail.com When requesting the REST API we are getting datetimes in the RFC3339 format, for instance: 2024-09-04T06:03:34-03:00 This is retrieving the value that is stored DB, and using the timezone defined in the $KOHA_CONF file. However this format is not correctly into account when we search or, more importantly, when we create/update objects. Examples (Using the Buenos Aires timezome, which is UTC-3 "America/Argentina/Buenos_Aires"): 1. POST /api/v1/patrons with "due_date": "2024-09-09T23:59:00-00:00", And you will get "due_date": "2024-09-09T23:59:00-03:00", in DB: date_due: 2024-09-09 23:59:00 2. GET /api/v1/jobs?q={"enqueued_on":{">":"2024-09-04T09:26:52-03:00"}} is generating the following query SELECT `me`.`id`, `me`.`status`, `me`.`progress`, `me`.`size`, `me`.`borrowernumber`, `me`.`type`, `me`.`queue`, `me`.`data`, `me`.`context`, `me`.`enqueued_on`, `me`.`started_on`, `me`.`ended_on` FROM `background_jobs` `me` WHERE `enqueued_on` > '2024-09-04T09:26:52-03:00' But when you run it manually, you get a warning: | Warning | 1292 | Truncated incorrect datetime value: '2024-09-04T09:26:52-03:00' | -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37831 Jonathan Druart <jonathan.druart@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dcook@prosentient.com.au, | |martin.renvoize@ptfs-europe | |.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37831 Jonathan Druart <jonathan.druart@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |nick@bywatersolutions.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37831 Jonathan Druart <jonathan.druart@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=36217 -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37831 --- Comment #1 from David Cook <dcook@prosentient.com.au> --- Yeah, bug 36217 is just one example where we send UTC but the server interprets it as whatever local time zone the DB is set to. -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37831 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |25621 Depends on| |36432 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=25621 [Bug 25621] Some tests in t/DateUtils.t fail when timezone is not UTC https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36432 [Bug 36432] Remove circular dependency from Koha::Object -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37831 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on| |36217 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36217 [Bug 36217] Jobs page include last hour filter does not work -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37831 --- Comment #2 from Jonathan Druart <jonathan.druart@gmail.com> --- For 2. We are not hitting the code that is supposed to deal with rfc3339 (in Koha::Object->attributes_from_api) because the date is in 'q'. Koha/REST/Plugin/Objects.pm 160 my ( $filtered_params, $reserved_params ) = $c->extract_reserved_params($args); 212 # Call the to_model function by reference, if defined 213 if ( defined $filtered_params ) { 214 215 # Apply the mapping function to the passed params 216 $filtered_params = 217 $result_set->attributes_from_api($filtered_params); 218 $filtered_params = 219 $c->build_query_params( $filtered_params, $reserved_params ); 220 } q is in $reserved_params; { q [ [0] "{\"enqueued_on\":{\">\":\"2024-09-04T09:26:52-03:00\"}}" ] } -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37831 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|enhancement |major -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37831 Jonathan Druart <jonathan.druart@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |37902 Summary|Timezone ignored when |[OMNIBUS] Timezone ignored |passing rfc3339 formatted |when passing rfc3339 |date |formatted date --- Comment #3 from Jonathan Druart <jonathan.druart@gmail.com> --- (In reply to Jonathan Druart from comment #0)
2. GET /api/v1/jobs?q={"enqueued_on":{">":"2024-09-04T09:26:52-03:00"}} is generating the following query
SELECT `me`.`id`, `me`.`status`, `me`.`progress`, `me`.`size`, `me`.`borrowernumber`, `me`.`type`, `me`.`queue`, `me`.`data`, `me`.`context`, `me`.`enqueued_on`, `me`.`started_on`, `me`.`ended_on` FROM `background_jobs` `me` WHERE `enqueued_on` > '2024-09-04T09:26:52-03:00'
But when you run it manually, you get a warning: | Warning | 1292 | Truncated incorrect datetime value: '2024-09-04T09:26:52-03:00' |
Moved to bug 37902. Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37902 [Bug 37902] Timezone ignored when passing rfc3339 formatted date (search 'q') -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37831 Jonathan Druart <jonathan.druart@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |37903 --- Comment #4 from Jonathan Druart <jonathan.druart@gmail.com> --- (In reply to Jonathan Druart from comment #0)
When requesting the REST API we are getting datetimes in the RFC3339 format, for instance: 2024-09-04T06:03:34-03:00
This is retrieving the value that is stored DB, and using the timezone defined in the $KOHA_CONF file.
However this format is not correctly into account when we search or, more importantly, when we create/update objects.
Examples (Using the Buenos Aires timezome, which is UTC-3 "America/Argentina/Buenos_Aires"):
1. POST /api/v1/patrons with "due_date": "2024-09-09T23:59:00-00:00", And you will get "due_date": "2024-09-09T23:59:00-03:00",
in DB: date_due: 2024-09-09 23:59:00
Moved to bug 37903. Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37903 [Bug 37903] Timezone ignored when passing rfc3339 formatted date (POST,PUT,PATCH) -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37831 Jonathan Druart <jonathan.druart@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |37904 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37904 [Bug 37904] Timezone ignored when passing rfc3339 formatted date (search embed) -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37831 Jonathan Druart <jonathan.druart@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on|36432 | --- Comment #5 from Jonathan Druart <jonathan.druart@gmail.com> --- Not caused by bug 36432. Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36432 [Bug 36432] Remove circular dependency from Koha::Object -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37831 Jonathan Druart <jonathan.druart@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on|36217 | Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36217 [Bug 36217] Jobs page include last hour filter does not work -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37831 Jonathan Druart <jonathan.druart@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |37905 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37905 [Bug 37905] Correctly fix the "last hour" filter on the job list -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37831 Jonathan Druart <jonathan.druart@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks|37905 | Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37905 [Bug 37905] Correctly fix the "last hour" filter on the job list -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37831 --- Comment #6 from Jonathan Druart <jonathan.druart@gmail.com> --- Created attachment 171401 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=171401&action=edit Bug 37831: Adjust timezone We didn't take into account the server's timezone. This does not feel right, we are not supposed to deal with time zone outside of Koha::DateUtils. -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37831 Jonathan Druart <jonathan.druart@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #171401|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org