Skip to content

Instantly share code, notes, and snippets.

@ThaddeusJiang
Last active October 19, 2022 04:59
Show Gist options
  • Star 23 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ThaddeusJiang/59b84bed6b8856200d83b4716534d0c5 to your computer and use it in GitHub Desktop.
Save ThaddeusJiang/59b84bed6b8856200d83b4716534d0c5 to your computer and use it in GitHub Desktop.
isLeapYear in TypeScript
function isLeapYear(year: number) {
return new Date(year, 1, 29).getDate() === 29
}
export default isLeapYear
@lhyUnited
Copy link

好活

@BedrockDigger
Copy link

当赏

@garily
Copy link

garily commented Feb 14, 2021

好活

@lychees
Copy link

lychees commented Feb 14, 2021

好活

@llkhs
Copy link

llkhs commented Feb 14, 2021

这个还得实例化,直接year除以4效率更高吧?

@ThaddeusJiang
Copy link
Author

这个还得实例化,直接year除以4效率更高吧?

1900 并不是闰年,
年被 100 整除时,需要同时被 400 整除才是闰年。

@Dream4ever
Copy link

这个还得实例化,直接year除以4效率更高吧?

1900 并不是闰年,
年被 100 整除时,需要同时被 400 整除才是闰年。

啊,可惜不能用emoji给你点赞。手动点个赞👍

@daiwa233
Copy link

好活🔥

@agatsumayuki
Copy link

fantastic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment