Skip to content
This repository has been archived by the owner on Jul 10, 2024. It is now read-only.

Date conversion F# program added #5630

Merged
merged 2 commits into from
Apr 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
open System

// Function to convert standard date format (year, month, day) to Julian date
let toJulianDate (year : int) (month : int) (day : int) : DateTime =
new DateTime(year, month, day)

// Function to convert Julian date to standard date format (year, month, day)
let fromJulianDate (date : DateTime) : int * int * int =
date.Year, date.Month, date.Day

// Example usage
[<EntryPoint>]
let main argv =
// Convert standard date format to Julian date
let julianDate = toJulianDate 2024 4 9
printfn "Julian date: %A" julianDate

// Convert Julian date to standard date format
let (year, month, day) = fromJulianDate julianDate
printfn "Standard date format: %d-%d-%d" year month day

0 // Return an integer exit code