diff options
Diffstat (limited to 'date-fns/examples/rollup/fp.js')
-rw-r--r-- | date-fns/examples/rollup/fp.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/date-fns/examples/rollup/fp.js b/date-fns/examples/rollup/fp.js new file mode 100644 index 0000000..41a29d0 --- /dev/null +++ b/date-fns/examples/rollup/fp.js @@ -0,0 +1,18 @@ +import addYears from 'date-fns/esm/fp/addYears' +import {formatWithOptions} from 'date-fns/esm/fp' +import {eo} from 'date-fns/esm/locale' + +const addFiveYears = addYears(5) +const dateToString = formatWithOptions({locale: eo}, 'd MMMM yyyy') + +const dates = [ + new Date(2017, 0 /* Jan */, 1), + new Date(2017, 1 /* Feb */, 11), + new Date(2017, 6 /* Jul */, 2) +] + +const formattedDates = dates + .map((date) => dateToString(addFiveYears(date))) + .join(', ') + +console.log(formattedDates === '1 januaro 2022, 11 februaro 2022, 2 julio 2022') |