carbon icon indicating copy to clipboard operation
carbon copied to clipboard

Reference: https://github.com/golang-module/carbon/pull/134#issuecomm…

Open DrOctavius opened this issue 2 years ago • 4 comments

#134

Adapted function "ToLayoutString" -> requires some code review and output testing!

log.Println(carbon.Now().SetLocale("en").Layout("02 January 2006"))
log.Println(carbon.Now().SetLocale("ro").Layout("02 January 2006"))
log.Println(carbon.Now().SetLocale("ru").Layout("02 January 2006"))
log.Println(carbon.Now().SetLocale("zh-CN").Layout("02 January 2006"))
The expected Output should be:
21 May 2022
21 Mai 2022
21 Май 2022
21 五月 2022

DrOctavius avatar May 21 '22 06:05 DrOctavius

Codecov Report

Merging #135 (c05c663) into master (5860827) will decrease coverage by 1.79%. The diff coverage is 51.35%.

@@            Coverage Diff             @@
##           master     #135      +/-   ##
==========================================
- Coverage   99.89%   98.10%   -1.80%     
==========================================
  Files          18       18              
  Lines        2897     3007     +110     
==========================================
+ Hits         2894     2950      +56     
- Misses          2       50      +48     
- Partials        1        7       +6     
Impacted Files Coverage Δ
helper.go 82.35% <0.00%> (-17.65%) :arrow_down:
outputer.go 92.48% <54.28%> (-7.52%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 5860827...c05c663. Read the comment docs.

codecov-commenter avatar May 21 '22 17:05 codecov-commenter

Yes, totally agree! i just wrote an algo! please test, review, adapt if needed! thanks!

Adapted function "ToLayoutString" -> you can now escape words

log.Println(carbon.Now().SetLocale("en").Layout("02 \\January \\2006 \\2010\\2020 January"))
log.Println(carbon.Now().SetLocale("zh-CN").Layout("02 \\January \\2006 \\2010\\2020 January"))
The expected Output should be:
21 January 2006 20102020 May
21 January 2006 20102020 五月

DrOctavius avatar May 21 '22 17:05 DrOctavius

Hey @gouguoyin, how are you? did you had some time to review? thanks!

DrOctavius avatar May 24 '22 06:05 DrOctavius

Hey @gouguoyin, how are you? did you had some time to review? thanks!

Thanks for your contribution, as the code changes are quite large, I'm reviewing and thinking if there is a more elegant way.

gouguoyin avatar May 24 '22 06:05 gouguoyin