style: 移除 emoji, 注释改为中文 (保留专业名词)
- 移除所有 Vue 组件和 README 中的 emoji (按钮文字、标题、功能列表) - 将 src 下所有英文注释改为中文, 保留专业名词 (RRULE, EXDATE, ICS 等) - 涉及文件: date.js, event-factory.js, ical-io.js, organize.js, recur.js, split.js, weekday.js, useCalendar.js, EventDetail.vue, App.vue, DropZone.vue, EventList.vue, HeaderBar.vue, README.md
This commit is contained in:
@@ -1,59 +1,58 @@
|
||||
/**
|
||||
* Centralized date-string utilities.
|
||||
* 集中式的日期字符串工具集。
|
||||
*
|
||||
* All date values in the app use the 'YYYY-MM-DD' (wall-clock) format.
|
||||
* These helpers are the single source of truth for formatting and
|
||||
* arithmetic on that format, replacing ad-hoc inline code that was
|
||||
* duplicated across organize.js, recur.js, useCalendar.js, and ical-io.js.
|
||||
* 应用内所有日期值统一使用 'YYYY-MM-DD' (本地墙钟时间) 格式。
|
||||
* 本模块是格式化与日期运算的唯一来源, 替代此前散落在 organize.js、
|
||||
* recur.js、useCalendar.js、ical-io.js 中的重复实现。
|
||||
*/
|
||||
|
||||
/** Pad a number to 2 digits with leading zero. */
|
||||
/** 将数字补零为 2 位字符串。 */
|
||||
export function pad2(n) {
|
||||
return String(n).padStart(2, '0')
|
||||
}
|
||||
|
||||
/** Convert a JS Date to 'YYYY-MM-DD' (local wall-clock). */
|
||||
/** 将 JS Date 转换为 'YYYY-MM-DD' (本地墙钟时间)。 */
|
||||
export function toISODate(date) {
|
||||
return `${date.getFullYear()}-${pad2(date.getMonth() + 1)}-${pad2(date.getDate())}`
|
||||
}
|
||||
|
||||
/** Parse 'YYYY-MM-DD' into { year, month, day } (month is 1-based). */
|
||||
/** 将 'YYYY-MM-DD' 解析为 { year, month, day } (month 为 1 基)。 */
|
||||
export function parseISODate(s) {
|
||||
const [y, m, d] = s.split('-').map(Number)
|
||||
return { year: y, month: m, day: d }
|
||||
}
|
||||
|
||||
/** Build a local JS Date at midnight from 'YYYY-MM-DD'. */
|
||||
/** 由 'YYYY-MM-DD' 构造本地午夜 JS Date。 */
|
||||
export function toDate(isoDate) {
|
||||
return new Date(isoDate + 'T00:00:00')
|
||||
}
|
||||
|
||||
/** Add `days` days to an ISO date string, return new ISO string. */
|
||||
/** 在 ISO 日期字符串上增加 `days` 天, 返回新的 ISO 字符串。 */
|
||||
export function addDays(isoDate, days) {
|
||||
const d = toDate(isoDate)
|
||||
d.setDate(d.getDate() + days)
|
||||
return toISODate(d)
|
||||
}
|
||||
|
||||
/** Whole-day difference between two ISO date strings (b - a). */
|
||||
/** 两个 ISO 日期字符串之间的整天差 (b - a)。 */
|
||||
export function daysBetween(isoA, isoB) {
|
||||
return Math.round((toDate(isoB) - toDate(isoA)) / (24 * 3600 * 1000))
|
||||
}
|
||||
|
||||
/** Today's date as 'YYYY-MM-DD' (local). */
|
||||
/** 今天的日期, 格式为 'YYYY-MM-DD' (本地)。 */
|
||||
export function todayISO() {
|
||||
return toISODate(new Date())
|
||||
}
|
||||
|
||||
/**
|
||||
* Current UTC timestamp in compact RFC 5545 form (e.g. '20260711T085008Z').
|
||||
* Used for DTSTAMP on new events.
|
||||
* 当前 UTC 时间戳, 紧凑 RFC 5545 格式 (如 '20260711T085008Z')。
|
||||
* 用于新事件的 DTSTAMP。
|
||||
*/
|
||||
export function nowCompactTimestamp() {
|
||||
return new Date().toISOString().replace(/[-:]/g, '').split('.')[0] + 'Z'
|
||||
}
|
||||
|
||||
/** Format a JS Date's time as 'HH:MM'. */
|
||||
/** 将 JS Date 的时间格式化为 'HH:MM'。 */
|
||||
export function toHHMM(date) {
|
||||
return `${pad2(date.getHours())}:${pad2(date.getMinutes())}`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user