Skip to content
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

[Feature Request] support utcOffset("+08:00") #1085

Closed
semdy opened this issue Sep 28, 2020 · 9 comments · Fixed by #1395
Closed

[Feature Request] support utcOffset("+08:00") #1085

semdy opened this issue Sep 28, 2020 · 9 comments · Fixed by #1395
Labels

Comments

@semdy
Copy link

semdy commented Sep 28, 2020

如题

@iamkun
Copy link
Owner

iamkun commented Sep 28, 2020

Yes, number in seconds and minutes are supported at the moment.

@iamkun
Copy link
Owner

iamkun commented Sep 28, 2020

Any demo of using string, please?

@semdy
Copy link
Author

semdy commented Sep 28, 2020

例如:utcOffset("+08:00"),参考地址:https://momentjs.com/docs/#/manipulating/utc-offset/

现在项目用到了moment+antd+fullcalendar,想把moment替换成dayjs,现在项目中utcOffset参数都是用的string,替换起来有点麻烦,还有可能引发其它bug。

@iamkun
Copy link
Owner

iamkun commented Sep 28, 2020

You can make a custom plugin to fix this at present.

let offset = '-03:30';

let [h, m] = offset.split(':');

let hours = Number.parseInt(h);
let minutes = Number.parseInt(m);

let totalMinutes = hours * 60 + (hours < 0 ? (-minutes) : minutes);
dayjs().utcOffset(totalMinutes)

@iamkun iamkun changed the title utcOffset第一个参数不支持字符串,而momemt支持 [Feature Request] support utcOffset("+08:00") Sep 28, 2020
@semdy
Copy link
Author

semdy commented Oct 13, 2020

will this bug fixed?

@iamkun
Copy link
Owner

iamkun commented Oct 14, 2020

True, would you like pulling request for this?

@iamkun iamkun added the good first issue Good for newcomers label Oct 14, 2020
@ognjenjevremovic
Copy link
Contributor

Hey @iamkun 👋 .
First of I'd like to thank you for the awesome library! 🥳

I wanted to contribute to the project and saw this issue still open and labeled as a good first issue, which is a great place to start for newcomers to the project (such as I am).
Can you confirm that issue is still open and with no work being done? Also, is it up for grabs? 🙂

I'd like to provide a PR for this issue.
Can you please provide more info on where one should start in order to address this feature request?

Many thanks! 🎉

@iamkun
Copy link
Owner

iamkun commented Feb 28, 2021

@ognjenjevremovic you are most welcome.

Ref here #1085 (comment)

ognjenjevremovic pushed a commit to ognjenjevremovic/dayjs that referenced this issue Mar 1, 2021
Provide support string support to utcOffset method. Valid string values
formats for utcOffset method are +HH:mm, -HH:mm, +HHmm and -HHmm.

✅ Closes: iamkun#1085
ognjenjevremovic pushed a commit to ognjenjevremovic/dayjs that referenced this issue Mar 1, 2021
Extend the current suite of utc unit tests by providing unit tests for
the utcOffset method with string arguments.

✅ Closes: iamkun#1085
@iamkun
Copy link
Owner

iamkun commented May 26, 2021

🎉 This issue has been resolved in version 1.10.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging a pull request may close this issue.

3 participants