Skip to content
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

24 Hour Time Added to Preferences and Functionality #1063

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions __tests__/__renderer__/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ describe('Test Preferences Window', () =>
checkRenderedItem('count-today');
});

test('Change time-24 to true', () =>
{
changeItemValue('time-24', true);
checkRenderedItem('time-24');
});

test('Change close-to-tray to false', () =>
{
changeItemValue('close-to-tray', false);
Expand Down
12 changes: 12 additions & 0 deletions js/time-math.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,17 @@ function validateTime(time)
return re.test(time);
}

/**
* Validates that a string is a valid 24 hour time, following the format of HH:MM
* @returns true if it's valid
*/
function validate24Time(time)
{
if (time.length < 5) { time = '0' + time; }
const re = new RegExp('^-?(0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$');
return re.test(time);
}

/**
* Get a difference between two dates.
* date1, or date2 should be javascript Date instance.
Expand Down Expand Up @@ -157,4 +168,5 @@ export {
sumTime,
validateDate,
validateTime,
validate24Time
};
2 changes: 2 additions & 0 deletions js/user-preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ function isValidView(view)

const defaultPreferences = {
'count-today': false,
'time-24': false,
'close-to-tray': true,
'minimize-to-tray': true,
'hide-non-working-days': false,
Expand Down Expand Up @@ -56,6 +57,7 @@ const defaultPreferences = {
// Handle Boolean Inputs
const booleanInputs = [
'count-today',
'time-24',
'close-to-tray',
'minimize-to-tray',
'hide-non-working-days',
Expand Down
1 change: 1 addition & 0 deletions locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
"systemDefault": "System Default",
"themes": "Themes",
"thu": "Thu",
"time24": "24 Hour Time",
"title": "Preferences",
"tue": "Tue",
"userPreferences": "User preferences",
Expand Down
Loading