MfGames.Nitride.Temporal

The package MfGames.Nitride.Temporal extends Nitride with time- and date-centric operations, extensions, and processes. It allows a site to be hide future posts, create a calendar of entries, or create a nested set of pages based on year, month, and day.

dotnet add package MfGames.Nitride.Temporal

This also has an extension method to include it into the builder.

        public static async Task<int> Main(string[] args)
        {
            NitrideBuilder builder = new NitrideBuilder(args)
                .UseTemporal(
                    config =>
                    {
                        config
                            .WithDateTimeZone("America/Chicago")
                            .WithDateOptionCommandLineOption();
                    });

            return await builder.RunAsync();
        }

NodaTime and Instants

This library is built on top of NodaTime, provides good time zone support, and had date-only objects before they were available in the base library.

In most cases, adding an Instant to an entity is sufficient to use most of the temporal functionality.

Instant instant;

var entityList = new Entity[]
{
    new Entity(instant),
};

var op = context.Resolve<FilterOutFutureInstant>();

var filteredList = entityList.Run(op).ToList();

Options

When the WithDateOptionCommandLineOption() is included in the module setup, it injects a --date option into the builders that allows a different date to be used for the “now” date which can be retrieved from the injectable TimeService as CurrentInstant and CurrentDateTime.

Examples