datetime object

অধিবর্ষ
অধিবর্ষ PowerShell ট্র্যাকে
function Test-Leap([int] $year) {
    (Get-Date -Year $year -Month 2 -Day 29).Month -eq 2
}

The main characteristic of a leap year is the second month (February) has 29 days instead of 28. In this approach we will use Get-Date with : $year for Year parameter, 2 for Month Parameter, and 29 for Day parameter, and this will give us a DateTime object. Next we access the Month property of this object and compare it with 2, if they are equal then the year is a leap year. In the event of a year is not a leap year, Get-Date for Month 2 and Day 29 in fact return a DateTime object of March the 1st, which mean the Month property now has the value of 3.

Get-Date cmdlet.

23 সেপ্টেম্বর 2026 · কাজে লেগেছে?

PowerShell ট্র্যাকে অধিবর্ষ অনুশীলনীর অন্য অ্যাপ্রোচগুলো

এই অনুশীলনীটি আমাদের কমিউনিটি যেভাবে অন্য ভাবেও সমাধান করেছে