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

Pre-Epoch DateTimes With Fractional Seconds Can't Be Serialized #312

Open
adamrodger opened this issue Jan 15, 2019 · 4 comments
Open

Pre-Epoch DateTimes With Fractional Seconds Can't Be Serialized #312

adamrodger opened this issue Jan 15, 2019 · 4 comments

Comments

@adamrodger
Copy link

This code works fine:

DateTime original = new DateTime(1969, 12, 31, 23, 59, 59);
MessagePackSerializer<DateTime> ser = MessagePackSerializer.Get<DateTime>();
byte[] b = ser.PackSingleObject(original);
Console.WriteLine(string,Join(", ", b));

---> 199, 12, 255, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255

but when I add fractions of a second the code breaks:

DateTime original = new DateTime(1969, 12, 31, 23, 59, 59).AddTicks(1); // 100ns
MessagePackSerializer<DateTime> ser = MessagePackSerializer.Get<DateTime>();
byte[] b = ser.PackSingleObject(original);

---> System.ArgumentOutOfRangeException : nanoseconds must be non negative value and lessor than 999,999,999.
Parameter name: nanoseconds
   at MsgPack.Timestamp.FromDateTime(DateTime value)
   at MsgPack.Serialization.DefaultSerializers.TimestampDateTimeMessagePackSerializer.PackToCore(Packer packer, DateTime objectTree)
   at MsgPack.Serialization.MessagePackSerializer`1.PackTo(Packer packer, T objectTree)
   at MsgPack.Serialization.MessagePackSerializer`1.PackSingleObjectAsBytes(T objectTree)
   at MsgPack.Serialization.MessagePackSerializer`1.PackSingleObject(T objectTree)

As far as I can tell this should be serialising to the Timestamp 96 format which supports pre-epoch timestamps and fractional seconds, but this seems to be a bug in the serialisation to Timestamp 96.

@adamrodger adamrodger changed the title Pre-Epoch DateTimes With Milliseconds Can't Be Serialized Pre-Epoch DateTimes With Fractional Seconds Can't Be Serialized Jan 15, 2019
@adamrodger
Copy link
Author

Sorry, just realised this is a duplicate of #296

Please could we release the fixed version? I notice there's a tag for v1.0.1 but the latest on nuget.org is 1.0.0

@yfakariya
Copy link
Member

Ah, sorry for delaying release. I've just busy to maintain source, but it should be fixed in fix/#296-1.1 branch. I will release the fix in few weeks.

@yfakariya
Copy link
Member

I forgot that it should be released as 1.0.1, but I also found that the released process failed. I will fix the pipeline and release it to the NuGet soon.

@yfakariya
Copy link
Member

I have just released 1.0.1 including fix of #296 (and #312) issues.

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