• 获取某日所在星期结束的date

    参数

    • date: Date
    • 可选__namedParameters: {
          firstDay?:
              | 0
              | 2
              | 1
              | 3
              | 4
              | 5
              | 6;
          weekOffset?: number;
      } = {}
      • 可选firstDay?:
            | 0
            | 2
            | 1
            | 3
            | 4
            | 5
            | 6
      • 可选weekOffset?: number

    返回 Date

    const getEnd = (date: string, options?: Parameters<typeof getEndOfWeek>[1]) => formatDate(getEndOfWeek(new Date(date), options));

    // 星期一为星期第一天
    getEnd('2023/04/19', { firstDay: 1 }); // '2023-04-23 00:00:00'
    getEnd('2023/04/20', { firstDay: 1 }); // '2023-04-23 00:00:00'
    getEnd('2023/04/16', { firstDay: 1 }); // '2023-04-16 00:00:00'
    getEnd('2023/04/10', { firstDay: 1 }); // '2023-04-16 00:00:00'

    // 星期天为星期第一天
    getEnd('2023/04/19'); // '2023-04-22 00:00:00'
    getEnd('2023/04/16'); // '2023-04-22 00:00:00'
    getEnd('2023/04/09'); // '2023-04-15 00:00:00'
    getEnd('2023/04/10'); // '2023-04-15 00:00:00'

    getStartOfWeek