feat: display time zones and times in time zones (#2636)

* fix: show observation datetime in the obs time zone

I.e. it doesn't offset the observation datetime into the viewer's time zone.

* test: adjust to literal times by default

* chore: update to date-fns 3.0

* wip: show time zone names with all times

* show time zone name whenever a time zone is passed to a formatting function
* store observation IANA time zone in Realm

Note that this required patching around a bug in Hermes in which it should be
returning a GMT offset for the short time zone but is instead just returning
GMT.

* fix: omit time zone for unuploaded obs

* feat: show relative time differences on ActivityItem headers

* fix: hide zone/offset on ObsEdit before upload when signed in

* fix: hide clock icon in activity item header in new default mode

Also

* stop using checkCamelAndSnakeCase when not necessary in DetailsTab.js
* make POJO types only refer to other POJO types
This commit is contained in:
Ken-ichi
2025-01-31 14:22:55 -08:00
committed by GitHub
parent 3fbb2c470a
commit 7e960d9010
23 changed files with 233 additions and 100 deletions

View File

@@ -0,0 +1,21 @@
diff --git a/node_modules/date-fns-tz/dist/cjs/_lib/tzIntlTimeZoneName/index.js b/node_modules/date-fns-tz/dist/cjs/_lib/tzIntlTimeZoneName/index.js
index 2211eee..c618343 100644
--- a/node_modules/date-fns-tz/dist/cjs/_lib/tzIntlTimeZoneName/index.js
+++ b/node_modules/date-fns-tz/dist/cjs/_lib/tzIntlTimeZoneName/index.js
@@ -16,10 +16,12 @@ function tzIntlTimeZoneName(length, date, options) {
exports.tzIntlTimeZoneName = tzIntlTimeZoneName;
function partsTimeZone(dtf, date) {
const formatted = dtf.formatToParts(date);
- for (let i = formatted.length - 1; i >= 0; --i) {
- if (formatted[i].type === 'timeZoneName') {
- return formatted[i].value;
- }
+ // Hack around https://github.com/facebook/hermes/issues/1601 and
+ // https://github.com/marnusw/date-fns-tz/issues/306 by assuming all
+ // parts after timeZoneName are actually a part of timeZoneName
+ const idx = formatted.map(part => part.type).indexOf('timeZoneName');
+ if ( idx ) {
+ return formatted.slice(idx, formatted.length).map(part => part.value).join( "" );
}
return undefined;
}