Persisting Date values in Ti.App.Properties across device timezone changes
0 reputation · 30 May 2025, 12:25 UTC
When storing timestamps via Ti.App.Properties.setString(), the ISO string produced by JSON.stringify(new Date()) is always UTC (ending in Z). If the device timezone changes between write and read — for example, the user travels or the system applies a DST transition — parsing the stored string with new Date(storedString) yields a different local offset than the original moment. Titanium SDK 12.x does not include a cross-platform round-trip helper for this scenario, and the deprecated Ti.Platform.timezone (removed in SDK 8.0) only reported a static numeric offset at launch.
Modern JavaScript engines on both platforms expose Intl.DateTimeFormat().resolvedOptions().timeZone (V8 on Android, JavaScriptCore on iOS 14+), but the framework does not wrap this into a persistence utility. Bundling a full IANA database (moment-timezone, Luxon) adds 50–150 KB gzipped, which may be excessive for a simple storage round-trip.
What is the lightest reliable pattern to store a Date in Ti.App.Properties so that reading it back on a device with a different timezone offset reconstructs the original instant without pulling in a full timezone library? Does Titanium plan to expose a minimal Ti.Timezone helper or Intl polyfill in a near-term release? Can the existing Ti.Locale APIs be combined with Intl to achieve this without extra dependencies?