Skip to content

Commit

Permalink
Update README.md (#59)
Browse files Browse the repository at this point in the history
* Update README.md

Add example of how to import and use zeroPad helper with a custom renderer.

* Update README.md

Shorten code block to focus only on the zeroPad function.
  • Loading branch information
keithburgie authored and ndresx committed Oct 30, 2019
1 parent 716bae6 commit ed15233
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,14 @@ import Countdown, { zeroPad, calcTimeDelta, formatTimeDelta } from 'react-countd
### `zeroPad(value, [length = 2])`
The `zeroPad` function works similar to other well-known pad-functions and takes 2 arguments into account. A `value` which can be a `string` or `number`, as well as a `length` parameter which defaults to `2` as you are most likely only going to use this function if you actually want to pad one of your values. Either returns a `number` if `length` equals `0`, or the zero-padded `string`.

```js
const renderer = ({ hours, minutes, seconds }) => (
<span>
{zeroPad(hours)}:{zeroPad(minutes)}:{zeroPad(seconds)}
</span>
);
```

<a name="calctimedelta"></a>
### `calcTimeDelta(date, [options])`
`calcTimeDelta` calculates the time difference between a given end [`date`](#date) and the current date (`now`). It returns, similar to the [`renderer`](#renderer) callback, a custom object (also referred to as **countdown time delta object**) with the following time related data:
Expand Down

0 comments on commit ed15233

Please sign in to comment.