Skip to content

Commit

Permalink
correct date parsing for sitemap input element
Browse files Browse the repository at this point in the history
  • Loading branch information
TAKeanice committed Nov 15, 2024
1 parent 0a70d0e commit 7eb6baf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
12 changes: 11 additions & 1 deletion openHAB/DatePickerUITableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ import OpenHABCore
import UIKit

class DatePickerUITableViewCell: GenericUITableViewCell {
static let dateFormatter = {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
return dateFormatter
}()

override var widget: OpenHABWidget! {
get {
super.widget
Expand All @@ -29,7 +35,11 @@ class DatePickerUITableViewCell: GenericUITableViewCell {
default:
fatalError("Must not use this cell for input other than date and time")
}
datePicker.date = ISO8601DateFormatter().date(from: widget.state) ?? Date.now
guard let date = widget.labelValue else {
datePicker.date = Date()
return
}
datePicker.date = Self.dateFormatter.date(from: date) ?? Date.now
}
}

Expand Down
1 change: 1 addition & 0 deletions openHAB/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
</constraints>
</tableViewCellContentView>
<connections>
<outlet property="customDetailTextLabelConstraint" destination="NfO-Ga-1yL" id="qaa-nK-0KP"/>
<outlet property="customTextLabel" destination="2sF-SD-siy" id="GjT-Fl-gux"/>
<outlet property="datePicker" destination="z76-h7-KYr" id="AgZ-MY-7HG"/>
</connections>
Expand Down

0 comments on commit 7eb6baf

Please sign in to comment.