Skip to content

Inconsistent encoding of Date values #1990

@bajtos

Description

@bajtos

Related to #1907, per strongloop-community/loopback-sdk-ios#83 (comment):

Data object is also encoded in two different ways:

  1. Method/callback arguments: { '$type': 'date', '$data': 'Thu Jan 01 1970 09:00:00 GMT+0900 (JST)' }
  2. Model properties: '1970-01-01T00:00:00.000Z' (a plain string)

The format difference is caused because date.toString() is used for the method/callback arg case, whereas it looks date.toISOString() is used for properties

I am proposing to unify this behaviour and always use the plain ISO date string encoding, which is used by JSON.stringify too.

In order to support older clients and make the upgrade path smoother, we should keep support of {$type,$data} format in input arguments.

Subtasks:

  • fix strong-remoting
  • fix iOS SDK

@raymondfeng @ritch @STRML @fabien thoughts?
/cc @hideya

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions