Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selected day not accurate #242

Open
jl-mobitech opened this issue Jun 8, 2023 · 2 comments
Open

Selected day not accurate #242

jl-mobitech opened this issue Jun 8, 2023 · 2 comments
Assignees
Labels
question Further information is requested

Comments

@jl-mobitech
Copy link

I am using HorizonCalendar that allows the user to select a date and enter some data based on the selected date. I am parsing the Day object to date like this:

let parsedDate = sharedDataStore.gregorianCalendar.date(from: day.components)!

sharedDataStore.gregorianCalendar's implementation is:
gregorianCalendar = Calendar(from: .gregorian)

Now for example, today's date is June 8, 2023 but when I am tapping June 7th, 2023, the parsedDate value is 2023-06-06 16:00:00 +0000

image

Any idea what's happening? I am currently on a country where the timezone is GMT +8, I don't know if it will help to diagnose my problem.

Also note, I am using a single instance of the calendar sharedDataStore.gregorianCalendar as I believe you mentioned that somewhere in the issues to only use one calendar.

Thanks!

@jl-mobitech
Copy link
Author

CaleandrViewRepresentable code:

CalendarViewRepresentable(calendar: vm.sharedDataStore.gregorianCalendar,
                          visibleDateRange: vm.startDateRange...Date(),
                          monthsLayout: .horizontal,
                          dataDependency: vm.selectedDate,
                          proxy: calendarViewProxy)
.dayItemProvider(dayItemProvider) //: DayItemProvider
.monthHeaderItemProvider(monthItemProvider) //: MonthHeaderItemProvider
.dayOfWeekItemProvider(dayOfWeekProvider) //: DayOfWeekItemProvider
.onDaySelection(vm.setDate)
.onAppear {
    calendarViewProxy.scrollToDay(containing: Date(),
                                  scrollPosition: .centered,
                                  animated: false)
}

@bryankeller
Copy link
Contributor

@jl-mobitech you might want to use Calendar.current. Just creating a calendar via Calendar(identifier: .gregorian) might not have it configured with the right info.

@bryankeller bryankeller self-assigned this Sep 18, 2023
@bryankeller bryankeller added the question Further information is requested label Sep 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants