Koyomi.FSharp 1.1.1

dotnet add package Koyomi.FSharp --version 1.1.1
NuGet\Install-Package Koyomi.FSharp -Version 1.1.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Koyomi.FSharp" Version="1.1.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Koyomi.FSharp --version 1.1.1
#r "nuget: Koyomi.FSharp, 1.1.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Koyomi.FSharp as a Cake Addin
#addin nuget:?package=Koyomi.FSharp&version=1.1.1

// Install Koyomi.FSharp as a Cake Tool
#tool nuget:?package=Koyomi.FSharp&version=1.1.1

Koyomi.FSharp

.NET Nuget

"Koyomi.FSharp" is a thin wrapper for System.DateTime. This can determine Japanese holidays and no configuration file or database maintenance is required.

Requirement

  • dotnet >= 8.0

Installation

Add Koyomi.FSharp as a dependency in your *.fsproj.

dotnet add Koyomi.FSharp

Usage

As a wrapper of System.DateTime

To use it like System.DateTime, do the following.

open System
open Koyomi.FSharp

let k = DateTime(2023, 12, 1) |> Koyomi.from
Koyomi.year k       // 2023
Koyomi.month k      // 12
Koyomi.date k       // 1
Koyomi.dayOfWeek k  // DayOfWeek.Sunday

Koyomi.addYears 1 k   // 2024-01-01
Koyomi.addMonths 1 k  // 2023-02-01
Koyomi.addDays 1 k    // 2023-01-02

Koyomi.format "yyyy/MM/dd" k  // 2023/01/01

Era(Japanese)

To derive the Japanese calendar, do the following.

open System
open Koyomi.FSharp

let e = DateTime(2023, 12, 1) |> Era.from
Era.name e         // 平成
Era.year e         // 5
Era.nameAndYear e  // 平成5年
Era.epoc e         // Reiwa(Discriminated union type)

Japanese holidays

To derive the Japanese holidays, do the following.

open System
open Koyomi.FSharp

let k = DateTime(2023, 1, 1) |> Koyomi.from
Koyomi.holiday k    // Some "元日"
Koyomi.isHoliday k  // true

let k = DateTime(2023, 1, 10) |> Koyomi.from
Koyomi.holiday k    // None
Koyomi.isHoliday k  // false

Japanese calendar

To use it as a Japanese calendar, do the following.

open System
open Koyomi.FSharp

// From the specified date to today.(Include specified date)
DateTime.Now.AddDays(-10) |> Calendar.from

// From today until the specified date.(Include specified date)
DateTime.Now.AddDays(10) |> Calendar.until

// Specifiy a range.
let from = DateTime.Now.AddDays(-10)
let until = DateTime.Not.AddDays(10)
Calendar.between from until

// An inconsistent range will return an empty list.
Calendar.between until from |> List.isEmpty  // true

You can also generate a calendar by specifying the year, month, or year.

open Koyomi.FSharp

// Specified year.
Calendar.ofYear DateTime.Now.Year

// Specified year and month.
Calendar.ofMonth DateTime.Now.Year DateTime.Now.Month

If you need only holidays, use ofHolidays.

open System
open Koyomi.FSharp

DateTime.Now.Year |> Calendar.ofYear |> Calendar.ofHolidays

Note

Koyomi.FSharp only handles dates. Hours, minutes, and seconds are not handled.

Author

panther-king

License

"Koyomi.FSharp" is under MIT licesnes.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.1 186 12/3/2023
1.1.0 91 12/3/2023
1.0.1 162 2/5/2023
1.0.0 147 2/5/2023