Skip to content

Commit d6a2aac

Browse files
committed
#869 | Display selected date and time in 12 hour format everywhere
1 parent 5b7b447 commit d6a2aac

File tree

5 files changed

+19
-11
lines changed

5 files changed

+19
-11
lines changed

packages/openchs-android/package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/openchs-android/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"lodash": "4.17.21",
5151
"moment": "2.29.4",
5252
"native-base": "3.4.9",
53-
"openchs-models": "1.27.24",
53+
"openchs-models": "1.27.25",
5454
"prop-types": "15.8.1",
5555
"react": "18.2.0",
5656
"react-native": "0.69.7",

packages/openchs-android/src/utility/General.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ class General {
7373
return `${General.toTwoChars(date.getDate())}-${General.toTwoChars(date.getMonth() + 1)}-${date.getFullYear()} ${hour}:${minutes}`;
7474
}
7575

76+
static to12HourDateTimeFormat(dateTime) {
77+
return moment(dateTime).format("lll");
78+
}
79+
80+
static to12HourDateFormat(dateTime) {
81+
return moment(dateTime).format("ll");
82+
}
83+
7684
static isoFormat(date) {
7785
return `${date.getFullYear()}-${General.toTwoChars(date.getMonth() + 1)}-${General.toTwoChars(date.getDate())}`;
7886
}

packages/openchs-android/src/views/primitives/DatePicker.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ class DatePicker extends AbstractComponent {
3333
return _.isNil(date)
3434
? this.I18n.t(noDateMessageKey)
3535
: (this.props.pickTime && !(General.hoursAndMinutesOfDateAreZero(date)))
36-
? General.formatDateTime(date)
37-
: General.formatDate(date);
36+
? General.to12HourDateTimeFormat(date)
37+
: General.to12HourDateFormat(date);
3838
}
3939

4040
showDatePicker() {

packages/openchs-android/src/views/primitives/TimePicker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class TimePicker extends AbstractComponent {
6565

6666
timeDisplay() {
6767
return _.isNil(this.props.timeValue)
68-
? this.I18n.t(this.noTimeMessageKey) : this.props.timeValue;
68+
? this.I18n.t(this.noTimeMessageKey) : General.toDisplayTime(this.props.timeValue);
6969
}
7070

7171
showTimePicker(options) {

0 commit comments

Comments
 (0)