Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/codecs/DateCodec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
const type = -1

function encode (dt) {
// zhe-li fix
if (dt === null) {
return
}
// zhe-li fix
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why these comments? can you remove them?


var millis = dt * 1
var seconds = Math.floor(millis / 1000)
var nanos = (millis - seconds * 1000) * 1e6
Expand Down
12 changes: 12 additions & 0 deletions test/datenull.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
var test = require('tape').test
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'use strict' is missing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fix all that:)

var msgpack = require('../')

test('encode date is null ', function (t) {
var encoder = msgpack({
disableTimestampEncoding: true
})

t.equal(encoder.encode(null)[0], 0xc0, 'encode null as null')

t.end()
})