Giter Site home page Giter Site logo

Comments (11)

Wxh16144 avatar Wxh16144 commented on July 19, 2024

复现地址404...

from ant-design.

faner11 avatar faner11 commented on July 19, 2024

@Wxh16144 可能是权限问题,你直接访问仓库吧
https://github.com/faner11/procomponents-dayjs

from ant-design.

Wxh16144 avatar Wxh16144 commented on July 19, 2024

感觉像 dayjs 的 bug 🤔

import dayjs from 'dayjs'
import advancedFormat from 'dayjs/plugin/advancedFormat'
import weekOfYear from 'dayjs/plugin/weekOfYear'
import weekYear from 'dayjs/plugin/weekYear'

dayjs.extend(weekOfYear)
dayjs.extend(weekYear)
dayjs.extend(advancedFormat)

dayjs('2024-02', 'gggg-ww', true).format('YYYY-MM-DD HH:mm:ss') // Invalid Date

from ant-design.

Wxh16144 avatar Wxh16144 commented on July 19, 2024

感觉像 dayjs 的 bug 🤔

估计和 #43246 (comment) 问题一样,不支持反向 format ...

CC. @iamkun

from ant-design.

faner11 avatar faner11 commented on July 19, 2024

@Wxh16144 我和你使用了同样的代码,我是正常的

import dayjs from 'dayjs';
import advancedFormat from 'dayjs/plugin/advancedFormat'
import weekOfYear from 'dayjs/plugin/weekOfYear'
import weekYear from 'dayjs/plugin/weekYear'
dayjs.extend(weekOfYear)
dayjs.extend(weekYear)
dayjs.extend(advancedFormat)

console.log(dayjs("2024-02","gggg-ww",true).format("YYYY-MM-DD HH:mm:ss")); // 2024-02-01 00:00:00

from ant-design.

zombieJ avatar zombieJ commented on July 19, 2024

dayjs 需要使用 WeekOfYear 插件才能支持 ww 格式。你在不使用 antd 组件的时候,相当于没有配置插件状态。dayjs 对于不支持的格式会进行模糊匹配,然后把 ww 当成月份转换(你的代码中 2024-02 并没有正确转换成对应的时间)。

在 antd 中,当你使用组件会被引入 WeekOfYear 插件,所以它会按照 ww 来匹配。但是由于 dayjs 又不支持 ww 解析。所以被降级成了当前时间。

这就相当于两个都是错的,我希望错的更一致一些一样。是没有意义的。可以考虑给 dayjs 提 issue 来支持这个能力哈~

from ant-design.

faner11 avatar faner11 commented on July 19, 2024

@zombieJ 我使用了 weekOfYear 插件,解析依然正常,但是使用Antd 组件就 返回 Invalid Date。问题没解决你别关闭呀

from ant-design.

Wxh16144 avatar Wxh16144 commented on July 19, 2024

我使用了 weekOfYear 插件,解析依然正常

你是指 dayjs().format('gggg-ww') 这样的用法正确么?

from ant-design.

faner11 avatar faner11 commented on July 19, 2024

dayjs().format('gggg-ww') 无论是否使用Antd 都是正确的

出问题的是 dayjs("2024-02","gggg-ww",true).format("YYYY-MM-DD HH:mm:ss")

from ant-design.

zombieJ avatar zombieJ commented on July 19, 2024

@zombieJ 我使用了 weekOfYear 插件,解析依然正常,但是使用Antd 组件就 返回 Invalid Date。问题没解决你别关闭呀

2024-02 按照 gggg-ww 解析出来的时间怎么可能是 2024-02-01,你设置的格式是 不是 2024-02 按照周格式解析出来是 2024-01-08 ~ 2024-01-14 这个时间段。

再看一下我的描述?~

from ant-design.

faner11 avatar faner11 commented on July 19, 2024

@zombieJ 对哦,没注意,时间也是错的

from ant-design.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.