react-native-datetimepicker / datetimepicker

React Native date & time picker component for iOS, Android and Windows

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

timeZoneName prop has no effect

jennyckaplan opened this issue · comments

Bug report

Summary

Passing in a time zone name from the IANA (TZDB) database name in https://en.wikipedia.org/wiki/List_of_tz_database_time_zones to the timeZoneName prop has no effect and does not display the time in the specified timezone. The time displayed remains the local timezone of the device instead. When I instead use the deprecated timeZoneOffsetInMinutes prop, the time is displayed in the proper timezone (but I do not want to use this deprecated prop).

Reproducible sample code

import DateTimePicker from "@react-native-community/datetimepicker";

<DateTimePicker
    // timeZoneOffsetInMinutes={540}
    timeZoneName={'Asia/Tokyo'}
    value={date}
    mode="datetime"
    onChange={(_, date) => {
        setDate(date);
    }}
/>

Steps to reproduce

  1. Pass in a timeZoneName to the datetime picker
  2. See that the timezone is not being reflected in the display

Describe what you expected to happen:

  1. Pass in a timeZoneName to the datetime picker
  2. See that the timezone is properly being reflected in the display

Environment info

I am using Expo. I am on version 49.0.21 of Expo.

npx react-native info output:

System:
  OS: macOS 14.1.2
  CPU: (10) arm64 Apple M1 Max
  Memory: 694.78 MB / 64.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 18.16.0
    path: ~/.asdf/installs/nodejs/18.16.0/bin/node
  Yarn:
    version: 1.22.19
    path: ~/.yarn/bin/yarn
  npm:
    version: 9.5.1
    path: ~/.asdf/plugins/nodejs/shims/npm
  Watchman:
    version: 2024.01.15.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.14.3
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.2
      - iOS 17.2
      - macOS 14.2
      - tvOS 17.2
      - watchOS 10.2
  Android SDK: Not Found
IDEs:
  Android Studio: Not Found
  Xcode:
    version: 15.1/15C65
    path: /usr/bin/xcodebuild
Languages:
  Java: Not Found
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.72.6
    wanted: 0.72.6
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: Not found
  newArchEnabled: Not found
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

Time zone name (If the problem you have is related to unexpected time / date. See list in https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).

datetimepicker version: 7.6.2

iOS / Android version: iOS 17.2

UPDATE: I tried upgrading to Expo SDK 50 (specifically, 50.0.6, and I'm still experiencing the same issue).

UPDATE PART 2: When I made the upgrade from Expo 49 to Expo 50, the npx expo install --fix command downgraded this library to version 7.6.1. Upgrading to version 7.6.2, and Expo 50 fixed this issue for me.