Travis build: 1506

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

View File

@ -430,6 +430,16 @@ average(1, 2, 3);
</details>
### _Uncategorized_
<details>
<summary>View contents</summary>
* [`getColonTimeFromDate`](#getcolontimefromdate)
* [`getMeridiemSuffixOfInteger`](#getmeridiemsuffixofinteger)
</details>
---
## 🔌 Adapter
@ -7888,6 +7898,48 @@ yesNo('Foo', true); // true
<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