Clock command

Δίσεκτο έτος
Δίσεκτο έτος στη διαδρομή Tcl

Using the clock command approach may be considered a "cheat" for this exercise.

set timestamp [clock scan "$year-02-28" -format {%Y-%m-%d}]
set next_day [clock add $timestamp 1 day]
set day [clock format $next_day -format {%d}]
expr {$day == 29}

By adding a day to February 28th for the year, you can see if the new day is the 29th or the 1st. If it is the 29th, then the year is a leap year.

Reference: clock manual page

Note

Under the hood, Tcl does have an internal helper function to test for leap years.

Translation missing: el.number.nth.ordinalized Sep 2026 · Σου φάνηκε χρήσιμη;

Άλλες προσεγγίσεις για την άσκηση Δίσεκτο έτος στη διαδρομή Tcl

Άλλοι τρόποι με τους οποίους η κοινότητά μας έλυσε αυτή την άσκηση