web-ridge / react-native-paper-dates

Smooth and fast cross platform Material Design date and time picker for React Native Paper
https://www.reactnativepaperdates.com
MIT License
642 stars 166 forks source link

Time not saved correctly AM and PM #226

Closed ArtsiomAstrouski closed 1 year ago

ArtsiomAstrouski commented 1 year ago

The library does not correctly save time on the clock and scoreboard. expo 47 . react18. https://user-images.githubusercontent.com/86202029/210060235-1c10a7ea-f28a-4208-ac3b-4484c8835365.mov

github-actions[bot] commented 1 year ago

Hey! Thanks for opening the issue. Can you provide a minimal repro which demonstrates the issue? Posting a snippet of your code in the issue is useful, but it's not usually straightforward to run. A repro will help us debug the issue faster. Please try to keep the repro as small as possible. The easiest way to provide a repro is on snack.expo.dev. If it's not possible to repro it on snack.expo.dev, then you can also provide the repro in a GitHub repository.

theBogdan10 commented 1 year ago

import React, { useCallback, useState } from "react" import { DatePickerModal, registerTranslation, TimePickerModal, en } from "react-native-paper-dates" import { useTheme, Provider } from "react-native-paper" import { Color } from "@constants/style"

type Props = { onCancel: () => void onChange: (date: any) => void visible: boolean }

registerTranslation("en", en)

export default ({ onChange, onCancel, visible }: Props) => { const [isDate, setIsDate] = useState(true) const [dataInfo, setDataInfo] = useState(undefined) const handleSearchClick = useCallback(() => setIsDate((prev) => !prev), []) const theme = useTheme()

const datetimePickerTheme = { ...theme, colors: { ...theme.colors, primary: Color.pink, }, }

const onClose = useCallback(() => { onCancel() handleSearchClick() }, [])

if (!visible) { return null }

return (

setDataInfo(item.date)} // same props as onConfirm but triggered without confirmed by user saveLabel="Next" // optional startYear={2020} // optional, default is 1800 endYear={2050} // optional, default is 2200 /> { console.log(item) onChange({ year: dataInfo?.getFullYear(), month: dataInfo?.getMonth(), day: dataInfo?.getDate(), hours: item.hours, minute: item.minutes, }) handleSearchClick() }} hours={12} // default: current hours minutes={14} // default: current minutes label="Select time" // optional, default 'Select time' uppercase={false} // optional, default is true cancelLabel="Cancel" // optional, default: 'Cancel' confirmLabel="Save" // optional, default: 'Ok' animationType="fade" // optional, default is 'none' locale="en" />

) }

https://user-images.githubusercontent.com/42887632/210074279-7e1958a5-aef1-4902-bfac-d5d0a5acafcb.mov Unfortunately, I can only provide an extended video and text of the code.

iM-GeeKy commented 1 year ago

@theBogdan10 I was able to reproduce your issue and you can create a patch with the following fix https://github.com/web-ridge/react-native-paper-dates/pull/228 while we wait for the fix to get merged and released.

iM-GeeKy commented 1 year ago

Closed by https://github.com/web-ridge/react-native-paper-dates/pull/230