ios – Is there a way implement a more granular DatePicker in SwiftUI?


I’m developing an interface for cataloguing artworks using SwiftUI. As different artworks will have varying levels of specificity in their dates, I’m not sure what the best way to go about implementing the date picking interface would be.

ex) An older artwork containing only a year “1818”

ex) A slightly newer artwork containing a year and month “June 1920”

ex) A modern artwork containing a specific date “January 10, 2024”

ex) Artworks containing ranges of varying granularity “April – October 2023”, “2023-2024”

I have some idea’s for how to implement this in the database, but am deterred by designing UI elements. SwiftUI’s DatePicker only gives the option to exclude exact times.

I thought about using individual pickers to choose “Year”, “Month”, and “Date” separately, then storing them as integers. However, I don’t know what could be done to ensure impossible dates like “February 31, 2020” don’t get created.

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img