Azure / amqpnetlite

AMQP 1.0 .NET Library
Apache License 2.0
396 stars 141 forks source link

Invalid DateTime conversion #579

Closed miqm closed 4 months ago

miqm commented 4 months ago

The method used to convert DateTime to miliseconds is invalid.

Following code returns different results:

const long epochTicks = 621355968000000000; // 1970-1-1 00:00:00 UTC
const long TicksPerMillisecond = 10000;

// The AmqpNetLite way:
Console.WriteLine((DateTime.MaxValue.ToUniversalTime().Ticks - epochTicks) / TicksPerMillisecond);

// The proper way:
Console.WriteLine((DateTime.MaxValue - DateTime.UnixEpoch).TotalMilliseconds);

result:

253402297199999
253402300800000

This blocks passing DateTime.MaxValue to Azure Service Bus get-message-sessions to retrieve all sessions as per discussion here: https://github.com/MicrosoftDocs/azure-docs/issues/119766

miqm commented 4 months ago

Thanks @xinchen10 , it works now. Looking forward for releasing new nuget package!

miqm commented 4 months ago

@xinchen10 any eta when you'll publish new nuget version with corrected timestamp?

xinchen10 commented 4 months ago

Release 2.4.9 is out.