Koyomi.FSharp 1.1.2

dotnet add package Koyomi.FSharp --version 1.1.2
                    
NuGet\Install-Package Koyomi.FSharp -Version 1.1.2
                    
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.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Koyomi.FSharp" Version="1.1.2" />
                    
Directory.Packages.props
<PackageReference Include="Koyomi.FSharp" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Koyomi.FSharp --version 1.1.2
                    
#r "nuget: Koyomi.FSharp, 1.1.2"
                    
#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.
#:package Koyomi.FSharp@1.1.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Koyomi.FSharp&version=1.1.2
                    
Install as a Cake Addin
#tool nuget:?package=Koyomi.FSharp&version=1.1.2
                    
Install as a Cake Tool

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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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.2 223 12/1/2024
1.1.1 298 12/3/2023
1.1.0 225 12/3/2023
1.0.1 324 2/5/2023
1.0.0 329 2/5/2023