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.

23 سپتامبر 2026 · برایتان مفید بود؟

رویکردهای دیگر برای تمرین سال کبیسه در مسیر Tcl

روش‌های دیگری که جامعه‌ی ما این تمرین را با آن‌ها حل کرده است