From a717976229c33c94b3c7d4b2778b66f34bb25f3f Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Mon, 3 Apr 2023 18:20:21 +0100 Subject: [PATCH] style!: rename parameter for DateTime.Age and DateTimeOffset.Age BREAKING CHANGE: "asOf" has been renamed to "referenceDate". Consumers using named parameters beware. --- CHANGELOG.md | 5 +++++ X10D/src/Time/DateTimeExtensions.cs | 4 ++-- X10D/src/Time/DateTimeOffsetExtensions.cs | 8 ++++---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1acffb8..74d7323 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 4.0.0 - [Unreleased] + +### Changed +- X10D: `DateTime.Age(DateTime)` and `DateTimeOffset.Age(DateTimeOffset)` parameter renamed from `asOf` to `referenceDate`. + ## [3.2.0] - 2023-04-03 ### Added diff --git a/X10D/src/Time/DateTimeExtensions.cs b/X10D/src/Time/DateTimeExtensions.cs index 2993b03..a89e613 100644 --- a/X10D/src/Time/DateTimeExtensions.cs +++ b/X10D/src/Time/DateTimeExtensions.cs @@ -30,9 +30,9 @@ public static class DateTimeExtensions #else [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] #endif - public static int Age(this DateTime value, DateTime asOf) + public static int Age(this DateTime value, DateTime referenceDate) { - return ((DateTimeOffset)value).Age(asOf); + return ((DateTimeOffset)value).Age(referenceDate); } /// diff --git a/X10D/src/Time/DateTimeOffsetExtensions.cs b/X10D/src/Time/DateTimeOffsetExtensions.cs index 977cc60..c1acbbf 100644 --- a/X10D/src/Time/DateTimeOffsetExtensions.cs +++ b/X10D/src/Time/DateTimeOffsetExtensions.cs @@ -30,10 +30,10 @@ public static class DateTimeOffsetExtensions /// Returns the rounded-down integer number of years since a given date as of another specified date. /// /// The date from which to calculate. - /// The date at which to stop calculating. + /// The date to use as the calculation reference. /// /// The rounded-down integer number of years since as of the date specified by - /// . + /// . /// [Pure] #if NETSTANDARD2_1 @@ -41,9 +41,9 @@ public static class DateTimeOffsetExtensions #else [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] #endif - public static int Age(this DateTimeOffset value, DateTimeOffset asOf) + public static int Age(this DateTimeOffset value, DateTimeOffset referenceDate) { - return (int)(((asOf.Date - TimeSpan.FromDays(1) - value.Date).TotalDays + 1) / 365.2425); + return (int)(((referenceDate.Date - TimeSpan.FromDays(1) - value.Date).TotalDays + 1) / 365.2425); } ///