Skip to content

useCalendarSwitch

Introduction

获取当前日期阳历或阴历的信息

Basic Usage

ts
import { useCalendarSwitch } from '@flypeng/tool/browser';

Type Declaration

ts
/**
 * 获取当前日期阳历或阴历的信息
 * @param date: date format yyyy-MM-dd
 * @param type: 'solar' | 'lunar'
 * @returns
 */
declare function useCalendarSwitch(
  date: string,
  type: 'solar' | 'lunar',
):
  | number
  | {
      lYear: number;
      lMonth: number;
      lDay: number;
      Animal: string;
      IMonthCn: string;
      IDayCn: string;
      cYear: number;
      cMonth: number;
      cDay: number;
      gzYear: string;
      gzMonth: string;
      gzDay: string;
      isToday: boolean;
      isLeap: boolean;
      nWeek: number;
      ncWeek: string;
      isTerm: boolean;
      Term: string | null;
      astro: string;
    };

Online Demo

useCalendarSwitch
获取当前日期阳历或阴历的信息
{ "lYear": 2024, "lMonth": 7, "lDay": 9, "Animal": "龙", "IMonthCn": "七月", "IDayCn": "初九", "cYear": 2024, "cMonth": 8, "cDay": 12, "gzYear": "甲辰", "gzMonth": "壬申", "gzDay": "戊申", "isToday": true, "isLeap": false, "nWeek": 1, "ncWeek": "星期一", "isTerm": false, "Term": null, "astro": "狮子座" }
<template>
  <div>{{ todayDateInfo1 }}</div>
</template>

<script setup lang="ts">
import { useFormatDate, useCalendarSwitch } from '@flypeng/tool/browser';

const todayDate = useFormatDate('yyyy-MM-dd');
const todayDateInfo1 = useCalendarSwitch(todayDate, 'lunar');
</script>

<style></style>

Released under the MIT License.