perf(upgrade dayjs's version): upgrade dayjs's version and set default timezone for dayjs#103
Open
Cythia828 wants to merge 1 commit intoDTStack:masterfrom
Open
perf(upgrade dayjs's version): upgrade dayjs's version and set default timezone for dayjs#103Cythia828 wants to merge 1 commit intoDTStack:masterfrom
Cythia828 wants to merge 1 commit intoDTStack:masterfrom
Conversation
liuxy0551
reviewed
Mar 28, 2025
src/dateTime.ts
Outdated
| * @param {string | number | Date} time - 输入时间 | ||
| * @return {dayjs.Dayjs} 带时区的Dayjs对象 | ||
| */ | ||
| const toLocalTime = (...args) => dayjs(...args).tz(DEFAULT_TIMEZONE); |
Collaborator
There was a problem hiding this comment.
这样是否可以呢
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')
.github/workflows/CI.yml
Outdated
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v2 | ||
| uses: actions/checkout@v4 |
c62f4d7 to
8d74394
Compare
8d74394 to
54531eb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
默认无特殊情况下,将客户现场显示的时间都定位到东八区去显示。