diff --git a/src/Nitride.Markdown/IdentifyMarkdown.cs b/src/Nitride.Markdown/IdentifyMarkdown.cs index 260fe09..edeedb1 100644 --- a/src/Nitride.Markdown/IdentifyMarkdown.cs +++ b/src/Nitride.Markdown/IdentifyMarkdown.cs @@ -39,8 +39,7 @@ public partial class IdentifyMarkdown : IOperation private Entity MarkBinaryEntities(Entity entity, UPath path, IBinaryContent binary) { - // If we aren't a Markdown file, then there is nothing - // we can do about that. + // If we aren't a Markdown file, then there is nothing we can do about that. if (!this.IsMarkdownTest(entity, path)) { return entity; diff --git a/src/Nitride.Temporal/Cli/DatePipelineCommandOption.cs b/src/Nitride.Temporal/Cli/DatePipelineCommandOption.cs index 016550c..e3f1592 100644 --- a/src/Nitride.Temporal/Cli/DatePipelineCommandOption.cs +++ b/src/Nitride.Temporal/Cli/DatePipelineCommandOption.cs @@ -18,14 +18,14 @@ namespace Nitride.Temporal.Cli; /// public class DatePipelineCommandOption : IPipelineCommandOption { - private readonly Timekeeper clock; + private readonly Timekeeper timekeeper; private readonly ILogger logger; - public DatePipelineCommandOption(ILogger logger, Timekeeper clock) + public DatePipelineCommandOption(ILogger logger, Timekeeper timekeeper) { this.logger = logger.ForContext(); - this.clock = clock; + this.timekeeper = timekeeper; this.Option = new Option("--date") { Description = "Sets the date to something other than now", @@ -42,19 +42,19 @@ public class DatePipelineCommandOption : IPipelineCommandOption // If we got a date, then use NodaTime's fake clock to set it so // everything will use that. var value = (DateTime?)context.ParseResult.GetValueForOption(this.Option); - + if (value.HasValue && value.Value != DateTime.MinValue) { // We have a date, so we need to create a fake clock that has this // date for the entire run. - Instant instant = this.clock.CreateInstant(value.Value); + Instant instant = this.timekeeper.CreateInstant(value.Value); - this.clock.Clock = new FakeClock(instant); + this.timekeeper.Clock = new FakeClock(instant); } // Report the date we are processing. - Instant now = this.clock.Clock.GetCurrentInstant(); - ZonedDateTime dateTime = now.InZone(this.clock.DateTimeZone); + Instant now = this.timekeeper.Clock.GetCurrentInstant(); + ZonedDateTime dateTime = now.InZone(this.timekeeper.DateTimeZone); string formatted = dateTime.ToString("yyyy-MM-dd HH:mm:ss x", CultureInfo.CurrentCulture); this.logger.Information("Setting date/time to {When:l}", formatted); diff --git a/src/Nitride.Temporal/NitrideTemporalBuilderExtensions.cs b/src/Nitride.Temporal/NitrideTemporalBuilderExtensions.cs index c640d55..dcb629a 100644 --- a/src/Nitride.Temporal/NitrideTemporalBuilderExtensions.cs +++ b/src/Nitride.Temporal/NitrideTemporalBuilderExtensions.cs @@ -53,13 +53,16 @@ public static class NitrideTemporalBuilderExtensions } }); - builder.ConfigureSite( - (_, scope) => - { - Timekeeper timekeeper = scope.Resolve(); + if (config.DateTimeZone != null) + { + builder.ConfigureSite( + (_, scope) => + { + Timekeeper timekeeper = scope.Resolve(); - timekeeper.DateTimeZone = timekeeper.DateTimeZone; - }); + timekeeper.DateTimeZone = config.DateTimeZone; + }); + } return builder; } diff --git a/src/Nitride.Temporal/NitrideTemporalConfiguration.cs b/src/Nitride.Temporal/NitrideTemporalConfiguration.cs index 5dc46e5..5546a67 100644 --- a/src/Nitride.Temporal/NitrideTemporalConfiguration.cs +++ b/src/Nitride.Temporal/NitrideTemporalConfiguration.cs @@ -1,5 +1,7 @@ using System; +using NodaTime; + namespace Nitride.Temporal; /// @@ -19,7 +21,7 @@ public partial class NitrideTemporalConfiguration /// Gets or sets the time zone to use for date time operations. Examples would be /// "America/Chicago". /// - public string? DateTimeZone { get; set; } + public DateTimeZone? DateTimeZone { get; set; } public string? Expiration { get; set; } @@ -28,6 +30,12 @@ public partial class NitrideTemporalConfiguration return this.WithAddDateOptionToCommandLine(true); } + public NitrideTemporalConfiguration WithDateTimeZone(string zoneName) + { + this.DateTimeZone = DateTimeZoneProviders.Tzdb[zoneName]; + return this; + } + /// /// Adds the "--expire" option into the pipeline commands where with the value set /// to diff --git a/src/Nitride.Temporal/Timekeeper.cs b/src/Nitride.Temporal/Timekeeper.cs index d570883..c24efdd 100644 --- a/src/Nitride.Temporal/Timekeeper.cs +++ b/src/Nitride.Temporal/Timekeeper.cs @@ -113,26 +113,4 @@ public class Timekeeper { return instant.InZone(this.DateTimeZone).ToDateTimeOffset().DateTime; } - - /// - /// Sets the clock used for time calculations. - /// - /// The new clock to use. - /// The instance for chaining methods. - public Timekeeper WithClock(IClock clock) - { - this.Clock = clock; - return this; - } - - /// - /// Sets the date time zone and returns itself for chaining. - /// - /// The name of the time zone. - /// The instance for chaining methods. - public Timekeeper WithDateTimeZone(string timeZoneName) - { - this.DateTimeZone = DateTimeZoneProviders.Tzdb[timeZoneName]; - return this; - } }