From a8c524f408deccfaf5bc18959e47afa319a43344 Mon Sep 17 00:00:00 2001 From: Johannes Vogel <31311694+johannes-vogel@users.noreply.github.com> Date: Mon, 21 Jul 2025 12:37:50 +0200 Subject: [PATCH] fix: precision for long dates --- lib/protocol/Writer.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/protocol/Writer.js b/lib/protocol/Writer.js index 28cf501..fd26013 100644 --- a/lib/protocol/Writer.js +++ b/lib/protocol/Writer.js @@ -861,7 +861,7 @@ Writer.prototype[TypeCode.LONGDATE] = function writeLongDate(value) { hours = ~~ts[4]; minutes = ~~ts[5]; seconds = ~~ts[6]; - nanoseconds = ~~((ts[6] * 1000000000) % 1000000000); + nanoseconds = ~~((ts[6] * 10000000) % 10000000); } else { throw createInputError('LONGDATE'); } @@ -877,7 +877,7 @@ Writer.prototype[TypeCode.LONGDATE] = function writeLongDate(value) { } const dayDate = calendar.DAYDATE(year, month, day); const dayFactor = BigInt(10000000) * BigInt(60 * 60 * 24); - const timeValue = BigInt(((hours * 60) + minutes) * 60 + seconds) * BigInt(10000000) + BigInt(~~(nanoseconds / 100)); + const timeValue = BigInt(((hours * 60) + minutes) * 60 + seconds) * BigInt(10000000) + BigInt(nanoseconds); const longDate = BigInt(dayDate - 1) * dayFactor + timeValue + BigInt(1); var buffer = new Buffer(9); buffer[0] = TypeCode.LONGDATE;