This moves the pure (albeit using the Intl browser API, see note) JS logic for data formatting/calculation into its own package, @thingco/data-transformers-core.
The React bindings are to be included in a separate package, @thingco/data-transformers-react
So:
add package @thingco/data-transformers-core
port tests across to use UVU
add sanitisation function for timestamps (if the timestamp is a string, convert to number, if the timestamp is a UNIX epoch, multiply by 1000 to allow it to be passed straight into JS' Date constructor).
Regarding the Intl API, I originally ripped it out and started writing formatting functions as a replacement, but going forward this makes it too difficult to reintrocuce localisation. So instead, will want to add a conditional polyfill for Android devices, and note that this will need each localisation file added.
This moves the pure (albeit using the
Intl
browser API, see note) JS logic for data formatting/calculation into its own package,@thingco/data-transformers-core
.The React bindings are to be included in a separate package,
@thingco/data-transformers-react
So:
@thingco/data-transformers-core
Date
constructor).Regarding the
Intl
API, I originally ripped it out and started writing formatting functions as a replacement, but going forward this makes it too difficult to reintrocuce localisation. So instead, will want to add a conditional polyfill for Android devices, and note that this will need each localisation file added.The polyfills are available here: https://formatjs.io/docs/polyfills/