1.0.5 • Published 9 months ago

json-date-fix v1.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

json-date-fix npm version

JSON serialization/deserialization fix for Date objects

import 'json-date-fix' // need once at the root of your app


// serialization fix: preserve timezone information
console.log(JSON.stringify(new Date(2023, 5, 7)));

// deserialization date-string to Date object
console.log(JSON.parse('"2023-06-07T00:00:00.000+03:00"'));


//// Console output:
// "2023-06-07T00:00:00.000+03:00"
// Wed Jun 07 2023 00:00:00 GMT+0300 (Moscow Standard Time)

Example with DateOnly format support

import jsonDateFix from './index.js'; 
jsonDateFix({ dateonly: true });  // enable dateonly format ('yyyy-MM-dd') analysis 


// deserialization dateonly-string to Date object
console.log(JSON.parse('"2023-06-07"'));

//// Console output:
// Wed Jun 07 2023 00:00:00 GMT+0300 (Moscow Standard Time)
1.0.5

9 months ago

1.0.4

9 months ago

1.0.3

9 months ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.1.0

3 years ago

0.0.1

3 years ago