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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

time: add MMM pattern support for parse_format() #19284

Merged
merged 2 commits into from Sep 6, 2023
Merged

time: add MMM pattern support for parse_format() #19284

merged 2 commits into from Sep 6, 2023

Conversation

jeffangelion
Copy link
Contributor

@jeffangelion jeffangelion commented Sep 6, 2023

Add three-letter month names parsing via time.parse_format()
Test code:

import time
a := time.now()
println(a)
b := a.custom_format('MMM DD HH:mm:ss YYYY')
println(b)
println(time.parse_format(b, 'MMM DD HH:mm:ss YYYY')!)

馃 Generated by Copilot at 2ca6223

Add support for parsing month names in different languages in time module. Use MMM format specifier and a new method to handle month abbreviations in date_time_parser.v.

馃 Generated by Copilot at 2ca6223

  • Add support for parsing month names in different languages using the MMM format specifier (link)
  • Call must_be_valid_three_letter_month method to parse and validate the month abbreviation from the input string (link)
  • Assign the returned month number to the month_ variable (link)
  • Implement must_be_valid_three_letter_month method for DateTimeParser struct (link)
    • Check that the input string has at least three characters (link)
    • Convert the first three characters to uppercase and compare them with a map of valid month abbreviations (link)
    • Return the corresponding month number or an error if the abbreviation is invalid (link)

@jeffangelion
Copy link
Contributor Author

Now it can be tested via time_test.v

@medvednikov medvednikov merged commit c790afa into vlang:master Sep 6, 2023
35 checks passed
Wertzui123 pushed a commit to Wertzui123/v that referenced this pull request Oct 8, 2023
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.

None yet

2 participants