@@ -27,7 +27,8 @@ const TypedStack = require('./serializer/typedstack');
2727
2828const baseDefaultOptions = {
2929 validate : true ,
30- ergo : false
30+ ergo : false ,
31+ utcOffset : 0 ,
3132} ;
3233
3334/**
@@ -85,6 +86,7 @@ class Serializer {
8586 * serialized in full, subsequent instances are replaced with a reference to the $id
8687 * @param {boolean } [options.convertResourcesToId] - Convert resources that
8788 * are specified for relationship fields into their id, false by default.
89+ * @param {number } [options.utcOffset] - UTC Offset for DateTime values.
8890 * @return {Object } - The Javascript Object that represents the resource
8991 * @throws {Error } - throws an exception if resource is not an instance of
9092 * Resource or fails validation.
@@ -114,7 +116,8 @@ class Serializer {
114116 options . permitResourcesForRelationships === true ,
115117 options . deduplicateResources === true ,
116118 options . convertResourcesToId === true ,
117- options . ergo === true
119+ options . ergo === true ,
120+ options . utcOffset ,
118121 ) ;
119122
120123 parameters . stack . clear ( ) ;
@@ -138,6 +141,7 @@ class Serializer {
138141 * in the place of strings for relationships, defaults to false.
139142 * @param {boolean } options.validate - validate the structure of the Resource
140143 * with its model prior to serialization (default to true)
144+ * @param {number } [options.utcOffset] - UTC Offset for DateTime values.
141145 * @return {Resource } The new populated resource
142146 */
143147 fromJSON ( jsonObject , options ) {
@@ -180,7 +184,7 @@ class Serializer {
180184 parameters . resourceStack = new TypedStack ( resource ) ;
181185 parameters . modelManager = this . modelManager ;
182186 parameters . factory = this . factory ;
183- const populator = new JSONPopulator ( options . acceptResourcesForRelationships === true , options . ergo === true ) ;
187+ const populator = new JSONPopulator ( options . acceptResourcesForRelationships === true , options . ergo === true , options . utcOffset ) ;
184188 classDeclaration . accept ( populator , parameters ) ;
185189
186190 // validate the resource against the model
0 commit comments