mirror of
https://github.com/immich-app/immich.git
synced 2025-01-01 08:31:59 +00:00
fix(web): Sort timezones in assets settings by offset (#10697)
* fixed timezones on web are sorted alphabetically * swaped order of operations in order to use DataTime.offset property for sorting * optimization
This commit is contained in:
parent
d00d33d8a5
commit
1d282851e2
1 changed files with 17 additions and 5 deletions
|
@ -12,7 +12,7 @@
|
||||||
/**
|
/**
|
||||||
* Timezone name
|
* Timezone name
|
||||||
*
|
*
|
||||||
* e.g. Europe/Berlin
|
* e.g. Asia/Jerusalem (+03:00)
|
||||||
*/
|
*/
|
||||||
label: string;
|
label: string;
|
||||||
|
|
||||||
|
@ -24,10 +24,22 @@
|
||||||
value: string;
|
value: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
const timezones: ZoneOption[] = Intl.supportedValuesOf('timeZone').map((zone: string) => ({
|
const timezones: ZoneOption[] = Intl.supportedValuesOf('timeZone')
|
||||||
label: zone + ` (${DateTime.local({ zone }).toFormat('ZZ')})`,
|
.map((zone) => DateTime.local({ zone }))
|
||||||
value: 'UTC' + DateTime.local({ zone }).toFormat('ZZ'),
|
.sort((zoneA, zoneB) => {
|
||||||
}));
|
let numericallyCorrect = zoneA.offset - zoneB.offset;
|
||||||
|
if (numericallyCorrect != 0) {
|
||||||
|
return numericallyCorrect;
|
||||||
|
}
|
||||||
|
return zoneA.zoneName.localeCompare(zoneB.zoneName, undefined, { sensitivity: 'base' });
|
||||||
|
})
|
||||||
|
.map((zone) => {
|
||||||
|
const offset = zone.toFormat('ZZ');
|
||||||
|
return {
|
||||||
|
label: `${zone.zoneName} (${offset})`,
|
||||||
|
value: 'UTC' + offset,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
const initialOption = timezones.find((item) => item.value === 'UTC' + initialDate.toFormat('ZZ'));
|
const initialOption = timezones.find((item) => item.value === 'UTC' + initialDate.toFormat('ZZ'));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue