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

Add timezone support #5061

Merged
merged 40 commits into from
Dec 18, 2020
Merged

Add timezone support #5061

merged 40 commits into from
Dec 18, 2020

Conversation

juanluisrp
Copy link
Contributor

@juanluisrp juanluisrp commented Sep 30, 2020

Before that, GeoNetwork was storing dates in the database in server timezone. Depending on the configuration dates could be displayed in a timezone which is different from the user timezone.

To improve that situation, this improvements adds:

  • The server time zone parameter is used to set the timezone of all dates not having a timezone specified

image

  • The default timezone of a fresh GeoNetwork installation will be UTC.

  • The user interface can define which timezone to use to render dates. For the simple case, it is recommended to set the server timezone and the user interface timezone to the same value it there is no need of multiple timezone support. browser can be used to render dates in current user timezone

image

  • Record view / settings to set the user timezone or (by default) use the browser timezone

image

  • Editor / Add timezone support

image

image

  • Remove Joda time library and use standard Java 8 java.time classes.

  • Migration / After setting the server timezone parameter, use v402.DateTimeMigrationTask migration task to update all db timezone.

This also means that when you create a new record, save and close, you don't have the status "updated one hour ago". If the title was not changed, it also contains the timezone information:

image

@juanluisrp juanluisrp mentioned this pull request Sep 30, 2020
10 tasks
@jodygarnett
Copy link
Contributor

jodygarnett commented Sep 30, 2020

Please pick up the ISODateTest timezone test from #5037

@fxprunayre fxprunayre linked an issue Oct 19, 2020 that may be closed by this pull request
10 tasks
@fxprunayre fxprunayre added this to the 4.0.0 milestone Oct 19, 2020
@fxprunayre fxprunayre changed the title Remove Joda time library Date handling Improvement Oct 20, 2020
@fxprunayre fxprunayre modified the milestones: 4.0.0, 4.0.1 Oct 20, 2020
@fxprunayre fxprunayre modified the milestones: 4.0.1, 4.0.2 Nov 6, 2020
@juanluisrp juanluisrp force-pushed the remove-joda-time branch 2 times, most recently from c540c41 to b31ac31 Compare November 23, 2020 07:30
@juanluisrp
Copy link
Contributor Author

juanluisrp commented Nov 30, 2020

Checked LinkStatus lastUpdate:

  • GeoNetwork UI
    image
  • Database
    image

UI is truncating the time to :00 seconds. Is that expected?

juanluisrp and others added 15 commits December 2, 2020 16:06
Remove Joda time library and use standard Java 8 java.time classes.

Part of #1970 (#1970).
Force entity to be saved.

```
[ERROR] Failures:
[ERROR]   GeonetRepositoryTest.testBatchUpdateAttributes:125 expected:<[Updated DataElem]> but was:<[<md>metadata12</md>]>
[ERROR]   MetadataRepositoryTest.testIncrementPopularity:95 expected:<33> but was:<32>
```

We don't really know why this is required and how it is linked to the Joda removal.
Use:
* `Browser` to use browser timezone
* otherwise define a specific timezone to use to display date eg.
`Australia/Hobart`

Add:
* Timezone directive / now support search by offset
* Timezone directive / display more values
Test working locally but not on travis:
```
[ERROR] UrlAnalyzerTest.urlCheckerToSetStatus:250 expected:<12> but was:<6>
```
Add code removed from MetadataUtils to XslUtils
See commit a5a6cd7
@jodygarnett
Copy link
Contributor

There is no great approach for dates without time, except perhaps storing them as a string, and then unpacking them as a date in the current timezone when asked.

Any attempt to limit them to a specific timezone is going to end up with glitches like metadata101/iso19139.ca.HNAP#135

juanluisrp and others added 4 commits December 9, 2020 11:14
Interpret the dates/ date-times appearing in the XML document as the timezone
set in the settings if the string hasn't a explicit time offset.
This commit adds a migration of the DateTime zones from the zone defined in
system timezone setting to UTC in case the date in the database doesn't have a
explicit timezone.
@juanluisrp
Copy link
Contributor Author

I've added a database migration to transform dates that don't have timezone defined into UTC dates using the system timezone setting.
Currently this migration isn't called automatically. It should be called manually using the /tools/migration/steps/v402.DateTimeMigrationTask API call once the administrator has set the right value in the server timezone setting.

@juanluisrp juanluisrp marked this pull request as ready for review December 16, 2020 15:21
@ianwallen
Copy link
Contributor

@juanluisrp I did a quick test of the changes and I noticed that the dates are not showing up for the status history.
Before the changes I get the following
image

With the changes from this PR I see the following.
image

Changes the behaviour introduced in #5144 [1] and uses the timezone setting
to print the date/time in new created metadata adding the timezone
to the date. For example "2020-12-17T03:58:29.074-05:00[America/Toronto]".

[1] #5144
@fxprunayre fxprunayre changed the title Date handling Improvement Add timezone support Dec 17, 2020
@juanluisrp
Copy link
Contributor Author

@juanluisrp I did a quick test of the changes and I noticed that the dates are not showing up for the status history.
Before the changes I get the following

Fixed @ianwallen
image

@fxprunayre fxprunayre merged commit 1e32d67 into 4.0.x Dec 18, 2020
@fxprunayre fxprunayre deleted the remove-joda-time branch January 8, 2021 11:59
@ianwallen
Copy link
Contributor

Any plans to backport this to the master/3.12?

@juanluisrp
I tested the status history with the latest 4.x changes and don't see the status history times. So it does not seem to have been fixed correctly?

@juanluisrp
Copy link
Contributor Author

I will check it @ianwallen.

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

Successfully merging this pull request may close these issues.

Date handling Improvement
5 participants