# ldesign-date-time **Repository Path**: ldesign-v1/ldesign-date-time ## Basic Information - **Project Name**: ldesign-date-time - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-10-18 - **Last Updated**: 2026-11-02 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # LDesign 日期与时间 这个包为日历、排班、考勤和日期选择器提供共享的日期与时区语义,本身不渲染选择器。 ## 它解决什么问题 生日 `2000-01-01` 是日历日期,不是 UTC 午夜对应的时间点;把它当作时间点转换时区,可能会显示成前一天。预约时间则需要结合用户所在时区转换成时间点,而且夏令时切换时,本地时间可能不存在,也可能重复一次。这个包让这些情况可以明确表达和处理。 `@composy/date-time-core` 提供纯日期、纯时间、日历运算、IANA 时区转换和格式化;`@composy/date-time-vue` 提供响应式的时区时间视图。 ## 安装 ```sh pnpm add @composy/date-time-core pnpm add @composy/date-time-vue vue ``` ## 处理预约时间 ```ts import { createPlainDate, formatInTimeZone, resolveZonedDateTime } from '@composy/date-time-core' const birthday = createPlainDate(2000, 1, 1) const appointment = resolveZonedDateTime( { year: 2024, month: 11, day: 3, hour: 1, minute: 30 }, 'America/New_York', 'later', ) console.log(birthday) // 保持为日历日期,不会因时区偏移 console.log(formatInTimeZone(appointment.epochMilliseconds, 'America/New_York')) ``` 转换时可选择 `compatible`、`earlier`、`later` 或 `reject` 来处理夏令时造成的缺失/重复本地时间。实现基于原生 `Intl`,不引入日期库;业务重复规则和选择器交互由调用方决定。