Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't encode/decode a Date object #19

Closed
xsellier opened this issue Mar 17, 2015 · 2 comments
Closed

Can't encode/decode a Date object #19

xsellier opened this issue Mar 17, 2015 · 2 comments

Comments

@xsellier
Copy link

Try this code:

var msgpack5  = require("msgpack5")();
var date = new Date();
console.log(date);
var result = msgpack5.decode(msgpack5.encode( {"date": date}));
console.log(result);

Output:

  Tue Mar 17 2015 11:17:52 GMT-0400 (EDT)
  { date: {} }
@mcollina
Copy link
Owner

Date is not included in the spec: https://github.com/msgpack/msgpack/blob/master/spec.md

I think it would be great if you write a little module that register an extension for encoding a Date, given a msgpack5 instance. If you are willing to write that module, I would definitely list in the README.

You should use https://github.com/mcollina/msgpack5#registerencodercheckobj-encodeobj and https://github.com/mcollina/msgpack5#registerdecodertype-decodebuf

@xsellier
Copy link
Author

Thank you for the quick answer, I will write a specific encoder/decoder for "Date" object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants