Skip to content

perf(upgrade dayjs's version): upgrade dayjs's version and set default timezone for dayjs #103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Cythia828
Copy link

@Cythia828 Cythia828 commented Mar 28, 2025

Do What

Upgrade dayjs's version and set default timezone for dayjs.

Change

Upgrade dayjs's version to 1.11.13. Then set default timezone to 'Asia/Shanghai'.

Where

By default, the time zone for on-site client displays is configured as UTC+8 (China Standard Time) unless otherwise specified.
默认无特殊情况下,将客户现场显示的时间都定位到东八区去显示。

* @param {string | number | Date} time - 输入时间
* @return {dayjs.Dayjs} 带时区的Dayjs对象
*/
const toLocalTime = (...args) => dayjs(...args).tz(DEFAULT_TIMEZONE);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这样是否可以呢

import dayjs as baseDayjs from 'dayjs'

export const dayjs = (...args, timezone = DEFAULT_TIMEZONE) => baseDayjs(...args).tz(timezone)

// 当前文件提供的方法
formatDateTime(timeData: string | number | Date) {
    return dayjs(timeData).format('YYYY-MM-DD HH:mm:ss');
}

// 子产品使用
import dayjs from 'dt-utils/dateTime'

dayjs(time).format('HH:mm')

@@ -15,10 +15,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ci 文件的变更考虑不在当前 PR 体现

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

单独提了一个PR
#104

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants