diff --git a/example/src/App.js b/example/src/App.js index 6fd6530..f2f9a13 100644 --- a/example/src/App.js +++ b/example/src/App.js @@ -1,10 +1,96 @@ -import React from 'react'; +import React, { useState } from 'react'; import ReactLiveTime from 'react-live-time'; export default function App() { + const [date, setDate] = useState(Date.now()); + const [format, setFormat] = useState('isoDateTime'); + const [showSeconds, setShowSeconds] = useState(false); + + const removeMinute = () => { + const __d = new Date(date); + setDate(__d.setMinutes(__d.getMinutes() - 1)); + }; + + const removeHour = () => { + const __d = new Date(date); + setDate(__d.setHours(__d.getHours() - 1)); + }; + + const resetDate = () => { + setDate(Date.now()); + }; + + const changeFormat = e => { + setFormat(e.target.value); + }; + + const changeShowSeconds = e => { + setShowSeconds(e.target.checked); + }; + return (
- +

DATE: {new Date(date).toLocaleString()}

+

+ ( + + {text}, {status}, {diff} + + )} + /> +

+

+ Remove hours or minutes: + + + + + +

+

+ For formatting values, check out{' '} + + mask options + {' '} + and{' '} + + named formats + + . Formatting powered by{' '} + + dateformat + + . +

); }