Skip to content

Commit

Permalink
- updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
rursache committed Feb 5, 2023
1 parent c5e43af commit ef1ca48
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion Files/RSDatePicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ public class RSDatePicker: UIView {
case .time: return .time
}
}

var defaultFormat: String {
switch self {
case .date: return "dd/MM/YYYY"
case .time: return "HH:mm"
}
}
}

// config
Expand Down Expand Up @@ -157,7 +164,7 @@ public class RSDatePicker: UIView {

private func didUpdateDate() {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = self.dateFormat ?? (self.pickerMode == .date ? "dd/MM/YYYY" : "HH:mm")
dateFormatter.dateFormat = self.dateFormat ?? (self.pickerMode?.defaultFormat ?? PickerMode.date.defaultFormat)
self.dateLabel.text = dateFormatter.string(from: self.currentDate)
}

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ You can customize the date picker in multiple ways:
- `initialDate` sets the default date
- `minimumDate` sets the minimum selectable date
- `maximumDate` sets the maximum selectable date
- `pickerMode` sets the date picker mode (`.date`, `time`, `.dateAndTime`)
- `pickerMode` sets the date picker mode (`.date` or `time`)
- `dateFormat` sets the date format for the visible label
- `closeWhenSelectingDate` allows you to enable/disable closing after a date was picked
- `closeAnimationDuration` controls the animation speed when closing the picker
Expand Down

0 comments on commit ef1ca48

Please sign in to comment.