Skip to content

Refactor date functions to use Carbon#64

Open
tassiocaique wants to merge 2 commits intomasterfrom
feature/refactor-dates-to-carbon-7993681689843259937
Open

Refactor date functions to use Carbon#64
tassiocaique wants to merge 2 commits intomasterfrom
feature/refactor-dates-to-carbon-7993681689843259937

Conversation

@tassiocaique
Copy link

This change refactors the date-related helper functions in Sysvale\Helpers\Dates to leverage the nesbot/carbon library. This improves the maintainability and internationalization of the codebase.

Key changes:

  1. getWeekDayNamePtBr: Now uses Carbon with the pt_BR locale to retrieve weekday names. Capitalization is preserved using ucfirst.
  2. getMonthNamePtBr: Now uses Carbon with the pt_BR locale to retrieve month names. Capitalization is preserved using ucfirst.
  3. parsePtDateToIsoDateFormat: Now uses Carbon::createFromFormat for robust date construction after handling the project-specific 2-digit year logic. Error handling is improved with a try-catch block returning null on failure.
  4. Dependencies: Added nesbot/carbon: ^2.66 to composer.json to ensure compatibility with the project's PHP 7.4 requirement, as Carbon 3 requires PHP 8.1+.

All existing tests pass, and the changes have been verified for both functionality and environment compatibility.

Fixes #50


PR created automatically by Jules for task 7993681689843259937 started by @tassiocaique

- Update getWeekDayNamePtBr to use Carbon for localized day names.
- Update getMonthNamePtBr to use Carbon for localized month names.
- Update parsePtDateToIsoDateFormat to use Carbon for parsing, while preserving legacy 2-digit year logic.
- Add nesbot/carbon ^2.66 as a dependency to maintain PHP 7.4 compatibility.

Co-authored-by: tassiocaique <7105035+tassiocaique@users.noreply.github.com>
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

- Refactored `getWeekDayNamePtBr`, `getMonthNamePtBr`, and `parsePtDateToIsoDateFormat` to use Carbon.
- Added `nesbot/carbon ^2.66` to `composer.json`.
- Configured `composer.json` with `prefer-stable: true` and pinned `platform.php` to `7.4.0` to ensure compatible dependencies are locked.
- Regenerated `composer.lock` to ensure all dependencies support PHP 7.4.

Co-authored-by: tassiocaique <7105035+tassiocaique@users.noreply.github.com>
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.

Análise das funções de datas

1 participant