Travis build: 1506
This commit is contained in:
52
README.md
52
README.md
@ -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
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -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.
|
||||
|
||||
```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
|
||||
|
||||
@ -76,7 +76,9 @@ functions:object,function
|
||||
gcd:math,recursion
|
||||
geometricProgression:math
|
||||
get:object
|
||||
getColonTimeFromDate:uncategorized
|
||||
getDaysDiffBetweenDates:date
|
||||
getMeridiemSuffixOfInteger:uncategorized
|
||||
getScrollPosition:browser
|
||||
getStyle:browser,css
|
||||
getType:type
|
||||
|
||||
Reference in New Issue
Block a user