Visitar URL original
Pre-Epoch DateTimes With Fractional Seconds Can't Be Serialized · Issue #312 · msgpack/msgpack-cli · GitHub
Skip to content

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

Description

@adamrodger

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.

Activity

  1. changed the title [-]Pre-Epoch DateTimes With Milliseconds Can't Be Serialized[/-] [+]Pre-Epoch DateTimes With Fractional Seconds Can't Be Serialized[/+] on Jan 15, 2019
  2. adamrodger commented on Jan 15, 2019

    @adamrodger
    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

  3. yfakariya commented on Feb 3, 2019

    @yfakariya
    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.

  4. yfakariya commented on Feb 3, 2019

    @yfakariya
    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.

  5. yfakariya commented on Feb 3, 2019

    @yfakariya
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions