-
-
Notifications
You must be signed in to change notification settings - Fork 948
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Respect time format system-wide #370
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -117,4 +117,30 @@ char const* DateTime::MonthsString[] = {"--", "JAN", "FEB", "MAR", "APR", "MAY", | |
char const* DateTime::MonthsStringLow[] = {"--", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; | ||
|
||
char const* DateTime::MonthsLow[] = { | ||
"--", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}; | ||
"--", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}; | ||
|
||
void DateTime::GetTimeStr(char* string, bool is24h) { | ||
char minutesChar[3]; | ||
sprintf(minutesChar, "%02d", static_cast<int>(minute)); | ||
char hoursChar[3]; | ||
char ampmChar[3] = " "; | ||
if (is24h) { | ||
sprintf(hoursChar, "%02d", hour); | ||
} else { | ||
if (hour == 0) { | ||
hour = 12; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a bug. This code was moved from elsewhere in the code where |
||
sprintf(ampmChar, "AM"); | ||
} else if (hour < 12) { | ||
sprintf(ampmChar, "AM"); | ||
} else if (hour >= 12) { | ||
hour = hour - 12; | ||
sprintf(ampmChar, "PM"); | ||
} | ||
sprintf(hoursChar, "%02d", hour); | ||
if (hoursChar[0] == '0') { | ||
hoursChar[0] = ' '; | ||
} | ||
} | ||
|
||
sprintf(string, "%c%c:%c%c %c%c", hoursChar[0], hoursChar[1], minutesChar[0], minutesChar[1], ampmChar[0], ampmChar[1]); | ||
Comment on lines
+123
to
+145
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can be reduced down to:
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a personal preference but I dislike using a
bool
as a stand-in for a two state enum. Making the second argument aClockType
instead would be better IMO. This would actually make the calling code simpler too since they all end up doing a comparison likesomeClockTypeVariable == ClockType::H24
now anyways.