ExtendedDatePicker

1.3.0

SwiftUI date picker with multiple modes
abdullah-original/ExtendedDatePicker

What's New

v1.3.0

2024-07-19T16:46:12Z
  • In week mode, the weeks will start on first of the week (Sunday/Monday depending on locale).
  • Some small improvements under the hood.

ExtendedDatePicker

DatePicker from SwiftUI only has two modes (date, and hourAndMinute) which for many cases is not sufficient. Often you need to switch between even more modes. ExtendedDatePicker solves this problem by providing extra modes that SwiftUI doesn't provide out of the box.

Hour Date DateTime Week MonthYear Year
Hour date dateTime week monthYear year

Installation

ExtendedDatePicker is available to be installed in your app via Swift Package Manager using the git url https://github.com/abdullah-original/ExtendedDatePicker.git.

Both a static and a dynamic library are provided.

Usage

ExtendedDatePicker(
  selectedDate: Binding<Date>,
  dateRange: ClosedRange<Date>,
  mode: DateMode,
  calendar: Calendar,
  options: ExtendedDatePickerOptions
)

Initialize the date picker as above. If you want to provide a custom locale or timezone, do so via the calendar parameter, otherwise the the default will be used.

In addition, some UI elements (such as back and forward arrows) can be customized using options: ExtendedDatePickerOptions parameter.

The client must provide at least selectedDate, dateRange, mode parameters. selectedDate is the state object that keeps track of currently selected date by user.

Info about date modes:

  • week: If the user has selected 2-8 February 2024, for example, selectedDate would be 2-2-2024.
  • monthYear: If the user has selected February 2024, for example, selectedDate would be x-2-2024. No guarantees are made about x.
  • year: If the user has selected 2024, for example, selectedDate would be x-y-2024. No guarantees are made about x or y.

In monthYear or year mode, client should just extract the relevent component from selectedDate i.e. calendar.component(.year, from: selectedDate).

Feedback

If you have any feedback or improvements to suggest, please free to open an issue.

Description

  • Swift Tools 5.9.0
View More Packages from this Author

Dependencies

  • None
Last updated: Sun May 04 2025 03:32:39 GMT-0900 (Hawaii-Aleutian Daylight Time)