skiptools / skiptools/skip-ui

DatePicker set a wrong date when choosing a date before today

Open
#165 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Swift
Stars
330
Forks
76
Avg merge
3h 6m
Merged PRs (30d)
1

Description

When using a DatePicker it store a wrong date if the the selection is before the current day. Everything's work fine when selecting a future date.
The date is displayed correctly on the picker selection interface, but after closing the picker it's reported incorrectly in the component, sometimes is the day before of the selected one, sometimes it's two days before.
I've created a sample app from the scratch with the latest packages to test if it was a bug in my application but the problem arise even in the test app.
Here's the sample View I've tested:

import SwiftUI

struct ContentView: View {
    @State private var selectedDate: Date = Date()
    
    var body: some View {
        VStack {
            Spacer()
            DatePicker("Select a date", selection: $selectedDate)
                .padding()
            Spacer()
        }
    }
}

Below few screenshots of the problem
You can see the selected date in the picker and after what's displayed in the component, when choosing for example March 22nd it then display March 21st, while it works fine when picking for example April 2nd (today is March 31st)

Image

Image

Image

Image

Image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with the provided ContentView and its DatePicker, comparing selections before and after today. Trace the DatePicker date conversion and reporting path in the repository. Done means selecting past dates reports the same calendar date after the picker closes, without changing future-date behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.