The use of PowerShell can be very convenient to judge a period is not a leap year, as long as a word to fix, isleapyear function, really revolutionary AH!
Small knitting before learning other languages, given a period of time, to judge it is a leap year or excepting, need to write large sections of code to achieve. When C # came out, the problem was resolved, and the DateTime type had a static method: Isleapyear (int year). Use this method to return true or false directly. True represents a leap year and false indicates excepting.
And look at the demo code:
Copy Code code as follows:
PS c:\users\zhanghong> [Datetime]::isleapyear (2013)
False
Do you want to explain it? It's easy. [DateTime] refers to a date and time type, and a double colon (::) is the meaning of calling a static method in PowerShell. The Isleapyear () function is used to judge leap years, excepting. Parameters are given directly to the function as a number.
Well, about PowerShell judge this year is not a leap years is the problem, this article on the introduction so much, I hope to help you, thank you!