1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- export const isLeapYear = function(year) {
- if (!typeof +year === 'number') {
- throw new Error("年份格式不正确");
- }
- if (+year < 1790) {
- throw new Error("年份不能低于1790年");
- }
-
-
-
- return (year % 4 === 0 && year % 100 !== 0) || (year % 400 === 0);
- };
- export const weekOfMonth = function(date) {
- if (!date) date = new Date();
- return new Date(getFullYear(date), getMonth(date), 1).getDay();
- };
- export const getMonth = function(date) {
- if (!date) date = new Date();
- return date.getMonth();
- };
- export const getFullYear = function(date) {
- if (!date) date = new Date();
- return date.getFullYear();
- };
- export const getDate = function(date) {
- if (!date) date = new Date();
- return date.getDate();
- };
- export default {
- isLeapYear,
- weekOfMonth,
- getMonth,
- getFullYear,
- getDate
- };
|