获取固有节假日的时间戳数组 (美国节假日)

使用的 getMonthDay方法

//固有节日节假日的时间戳
export const getFixedFestival = function () {
  let year = new Date().getFullYear();
  //新年1.1 -- 放一天
  // 7月4日 独立日(Independence Day) --放一天
  // 11.11 老兵节
  //圣诞节  -- 12.25 放两天
  //以及周末
  let stringArr = [];
  stringArr.push(new Date(`${year}/1/1`).getTime());
  stringArr.push(new Date(`${year}/7/4`).getTime());
  stringArr.push(new Date(`${year}/11/11`).getTime() );
  stringArr.push(new Date(`${year}/12/25`).getTime()  );
  stringArr.push(new Date(`${year}/12/26`).getTime());
  stringArr.push(new Date(getMartinLutherKingDay()).getTime());
  stringArr.push(new Date(getPresidentDay()).getTime());
  stringArr.push(new Date(getMemorialDay()).getTime());
  stringArr.push(new Date(getLaborDay()).getTime());
  stringArr.push(new Date(getColumbusDay()).getTime());
  stringArr.push(new Date(getThanksGivingDay()).getTime());
  return stringArr;
}

//计算马丁路德金纪念日 -- 一月份第三个星期一 放假一天
export const getMartinLutherKingDay = function () {
  return getMonthDay(1,3,1);
}

//计算总统日 -- 二月份第三个星期一 -- 放一天
export const getPresidentDay = function () {
  return getMonthDay(2,3,1);
}

// //计算阵亡将士纪念日 -- (五月的最后一个星期一)  放假一天
export const getMemorialDay = function () {
  return getMonthDay(5,-1,1);
}

// //计算劳动日 -- 九月的第一个星期一) 放假一天
export const getLaborDay = function () {
  return getMonthDay(9,1,1);
}

//计算哥伦布日 ---十月第二个星期一 放假一天
export const getColumbusDay = function () {
  return getMonthDay(10,2,1);
}

//计算感恩节 -- 十一月第四个星期天 
export const getThanksGivingDay = function () {
  return getMonthDay(11,4,4);
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值