How to resolve the algorithm Discordian date step by step in the Tcl programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Discordian date step by step in the Tcl programming language
Table of Contents
Problem Statement
Convert a given date from the Gregorian calendar to the Discordian calendar.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Discordian date step by step in the Tcl programming language
Source code in the tcl programming language
package require Tcl 8.5
proc disdate {year month day} {
# Get the day of the year
set now [clock scan [format %02d-%02d-%04d $day $month $year] -format %d-%m-%Y]
scan [clock format $now -format %j] %d doy
# Handle leap years
if {!($year%4) && (($year%100) || !($year%400))} {
if {$doy == 60} {
return "St. Tib's Day, [expr {$year + 1166}] YOLD"
} elseif {$doy > 60} {
incr doy -1
}
}
# Main conversion to discordian format now that special cases are handled
incr doy -1; # Allow div/mod to work right
set season [lindex {Chaos Discord Confusion Bureaucracy {The Aftermath}} \
[expr {$doy / 73}]]
set dos [expr {$doy % 73 + 1}]
incr year 1166
return "$season $dos, $year YOLD"
}
puts [disdate 2010 7 22]; # Today
puts [disdate 2012 2 28]
puts [disdate 2012 2 29]
puts [disdate 2012 3 1]
You may also check:How to resolve the algorithm Largest int from concatenated ints step by step in the Sidef programming language
You may also check:How to resolve the algorithm Here document step by step in the Ursala programming language
You may also check:How to resolve the algorithm Fast Fourier transform step by step in the APL programming language
You may also check:How to resolve the algorithm Munchausen numbers step by step in the C programming language
You may also check:How to resolve the algorithm Plot coordinate pairs step by step in the PureBasic programming language