forked from AnarchoTechNYC/NYCAnarchistEvents
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Actually include one-off event sources, make a
utils.js
kitchen sink.
- Loading branch information
Showing
4 changed files
with
36 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* Simplistic and "good enough" helper functions, mostly for dealing | ||
* with common one-off event source type issues. | ||
*/ | ||
|
||
/** | ||
* Simplistically converts a 12-hour time format string to a 24-hour time. | ||
* | ||
* @param str {String} The 12-hour formatted time string, e.g., `"8:00 am"` | ||
* @return | ||
*/ | ||
export function convert12To24HourTime (str) { | ||
var h; | ||
var m; | ||
if ( str.match(/ am$/) ) { | ||
[h, m] = str.match(/^(\d?\d):(\d\d)/).slice(1); | ||
if ( '12' === h ) { | ||
h = '00'; | ||
} | ||
} else { | ||
h = parseInt(str.match(/^\d?\d/)[0]) + 12; | ||
m = str.match(/:(\d\d) /)[1]; | ||
if ( '24' === h ) { | ||
h = '12'; | ||
} | ||
} | ||
h.toString().padStart(2, '0'); | ||
return [h, m]; | ||
} |