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": 12,
"lDay": 1,
"Animal": "龙",
"IMonthCn": "腊月",
"IDayCn": "初一",
"cYear": 2024,
"cMonth": 12,
"cDay": 31,
"gzYear": "甲辰",
"gzMonth": "丙子",
"gzDay": "己巳",
"isToday": true,
"isLeap": false,
"nWeek": 2,
"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>