Travis build: 1506

This commit is contained in:
30secondsofcode
2018-02-02 11:05:56 +00:00
parent 1965d15bb8
commit e7007e4e05
4 changed files with 70 additions and 3 deletions

View File

@ -430,6 +430,16 @@ average(1, 2, 3);
</details> </details>
### _Uncategorized_
<details>
<summary>View contents</summary>
* [`getColonTimeFromDate`](#getcolontimefromdate)
* [`getMeridiemSuffixOfInteger`](#getmeridiemsuffixofinteger)
</details>
--- ---
## 🔌 Adapter ## 🔌 Adapter
@ -7888,6 +7898,48 @@ yesNo('Foo', true); // true
<br>[⬆ Back to top](#table-of-contents) <br>[⬆ Back to top](#table-of-contents)
---
## _Uncategorized_
### getColonTimeFromDate
Returns a string of the form `HH:MM:SS` from a `Date` object.
Use `Date.toString()` and `String.slice()` to get the `HH:MM:SS` part of a given `Date` object.
```js
const getColonTimeFromDate = date => date.toTimeString().slice(0, 8);
```
```js
getColonTimeFromDate(new Date()); // "08:38:00"
```
<br>[⬆ back to top](#table-of-contents)
### getMeridiemSuffixOfInteger
Converts an integer to a suffixed string, adding `am` or `pm` based on its value.
Use the modulo operator (`%`) and conditional checks to transform an integer to a stringified 12-hour format with meridiem suffix.
```js
const getMeridiemSuffixOfInteger = num =>
num === 0 || num === 24
? 12 + 'am'
: num === 12 ? 12 + 'pm' : num < 12 ? num % 12 + 'am' : num % 12 + 'pm';
```
```js
getMeridiemSuffixOfInteger(0); // "12am"
getMeridiemSuffixOfInteger(11); // "11am"
getMeridiemSuffixOfInteger(13); // "1pm"
getMeridiemSuffixOfInteger(25); // "1pm"
```
<br>[⬆ back to top](#table-of-contents)
## Collaborators ## Collaborators

File diff suppressed because one or more lines are too long

View File

@ -5,7 +5,10 @@ Converts an integer to a suffixed string, adding `am` or `pm` based on its value
Use the modulo operator (`%`) and conditional checks to transform an integer to a stringified 12-hour format with meridiem suffix. Use the modulo operator (`%`) and conditional checks to transform an integer to a stringified 12-hour format with meridiem suffix.
```js ```js
const getMeridiemSuffixOfInteger = num => num === 0 || num === 24 ? 12 + "am" : num === 12 ? 12 + "pm" : num < 12 ? (num % 12) + "am" : (num % 12) + "pm"; const getMeridiemSuffixOfInteger = num =>
num === 0 || num === 24
? 12 + 'am'
: num === 12 ? 12 + 'pm' : num < 12 ? num % 12 + 'am' : num % 12 + 'pm';
``` ```
```js ```js

View File

@ -76,7 +76,9 @@ functions:object,function
gcd:math,recursion gcd:math,recursion
geometricProgression:math geometricProgression:math
get:object get:object
getColonTimeFromDate:uncategorized
getDaysDiffBetweenDates:date getDaysDiffBetweenDates:date
getMeridiemSuffixOfInteger:uncategorized
getScrollPosition:browser getScrollPosition:browser
getStyle:browser,css getStyle:browser,css
getType:type getType:type