From 9b044f8382a1e17f2bd6798460ba7a5e8c5c0880 Mon Sep 17 00:00:00 2001
From: johnboyerkarbonhq <142189602+johnboyerkarbonhq@users.noreply.github.com>
Date: Mon, 24 Feb 2025 14:06:10 +1100
Subject: [PATCH 1/2] Fix round method
---
src/NHibernate/Type/AbstractDateTimeType.cs | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/NHibernate/Type/AbstractDateTimeType.cs b/src/NHibernate/Type/AbstractDateTimeType.cs
index fb19752351..32838d0774 100644
--- a/src/NHibernate/Type/AbstractDateTimeType.cs
+++ b/src/NHibernate/Type/AbstractDateTimeType.cs
@@ -96,8 +96,11 @@ public object Next(object current, ISessionImplementor session) =>
/// The value to round.
/// The resolution in ticks (100ns).
/// A rounded .
- public static DateTime Round(DateTime value, long resolution) =>
- value.AddTicks(-(value.Ticks % resolution));
+ public static DateTime Round(DateTime value, long resolution)
+ {
+ var remainder = value.Ticks % resolution;
+ return remainder * 2 >= resolution ? value.AddTicks(resolution - remainder) : value.AddTicks(-remainder);
+ }
///
public virtual object Seed(ISessionImplementor session) =>
From b741d2b8f08b1890ad8db30fbed7a2d18f8ba3e1 Mon Sep 17 00:00:00 2001
From: johnboyerkarbonhq <142189602+johnboyerkarbonhq@users.noreply.github.com>
Date: Mon, 24 Feb 2025 14:07:43 +1100
Subject: [PATCH 2/2] Spaces to tabs
---
src/NHibernate/Type/AbstractDateTimeType.cs | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/NHibernate/Type/AbstractDateTimeType.cs b/src/NHibernate/Type/AbstractDateTimeType.cs
index 32838d0774..ce530a32ba 100644
--- a/src/NHibernate/Type/AbstractDateTimeType.cs
+++ b/src/NHibernate/Type/AbstractDateTimeType.cs
@@ -98,9 +98,9 @@ public object Next(object current, ISessionImplementor session) =>
/// A rounded .
public static DateTime Round(DateTime value, long resolution)
{
- var remainder = value.Ticks % resolution;
- return remainder * 2 >= resolution ? value.AddTicks(resolution - remainder) : value.AddTicks(-remainder);
- }
+ var remainder = value.Ticks % resolution;
+ return remainder * 2 >= resolution ? value.AddTicks(resolution - remainder) : value.AddTicks(-remainder);
+ }
///
public virtual object Seed(ISessionImplementor session) =>