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

Refactor and document Persian date handling #27

Merged
merged 6 commits into from
Oct 3, 2024
Merged

Refactor and document Persian date handling #27

merged 6 commits into from
Oct 3, 2024

Conversation

hootanht
Copy link
Owner

@hootanht hootanht commented Oct 2, 2024

PR Classification

New feature and documentation enhancement.

PR Summary

This PR introduces new functionality for date conversion between Persian (Shamsi) and Gregorian calendars, adds string utility methods, and enhances documentation.

  • PersianDateShamsi.cs: Added methods for DateTimeOffset, refactored for readability, and improved error handling.
  • ToGregorian.cs: Introduced a new class for converting Shamsi dates to Gregorian dates.
  • StringUtil.cs: Added a new static class with utility methods for string operations.
  • DateTest.cs and ToGregorianTest.cs: Refactored and added new unit tests.
  • README.md: Significantly updated for clarity, added installation instructions, usage examples, and version history.

Updated `using` directive to include `System.Globalization`. Reformatted `namespace` declaration. Added comprehensive XML documentation to `PersianDateShamsi` class and its methods. Refactored methods to handle `DateTimeOffset` and `DateTime` inputs separately. Added new methods for Shamsi date handling. Improved readability and maintainability of `ToShamsi.cs`, `DateTest.cs`, and `ToShamsiTest.cs` files with reorganized code and added XML comments. Enhanced test coverage for `DateTimeOffset` and null values.
Introduced the `ToGregorian` class in `ToGregorian.cs` to convert Persian (Shamsi) dates to Gregorian dates. This class includes methods to get the Gregorian year, month, day, date string, day name, and to convert a range of Shamsi dates to Gregorian dates.

Added a new test class `ToGregorianTest` in `ToGregorianTest.cs` to provide unit tests for the `ToGregorian` class. This includes tests for methods like `GetGregorianYear`, `ToGregorianDate`, `GetGregorianMonth`, `GetGregorianDay`, `GetGregorianDateString`, `GetGregorianDayName`, `GetDayNameFromPersianCharacter`, `ConvertRangeToGregorian`, and `GetFirstDayOfShamsiMonth`.

Added the `StringUtil` class in `StringUtil.cs` to provide utility methods for string operations. This includes methods to convert iOS keyboard and Arabic characters to Persian characters, check if a string contains Persian characters, reverse a string, and convert a string to title case.
The README.md file has been significantly updated to improve clarity, structure, and content. Key changes include:

- Updated title and description for better readability.
- Added badges for NuGet version, downloads, and build status.
- Introduced a new "Features" section.
- Added "Installation" instructions for NuGet.
- Expanded usage examples with more detailed code snippets.
- Added a "Version History" section.
- Included guidelines for contributing.
- Specified the MIT License.
- Added a support section for issue reporting.
- Enhanced "Getting Started" instructions.
- Removed outdated and redundant sections.
Updated PersianDateShamsi package version from 1.0.6 to 1.0.7 in PersianDate.csproj.
Enhanced README.md with example outputs for various methods:
- GetShamsiMonthName, GetShamsiDayString, GetShamsiDayName, GetShamsiDayShortName
- Extension methods: ToShamsiDate, ToShortShamsiDate, ToLongShamsiDate
- Gregorian conversion methods: GetGregorianYear, ToGregorianDate, GetGregorianMonth, GetGregorianDay

Updated version history in README.md to include version 1.0.7, noting support for DateTimeOffset in ToGregorian class and updates to PersianDateShamsi.cs and ToShamsi.cs.
Introduced an MIT License to the project, granting permissions for use, copy, modification, merging, publishing, distribution, sublicensing, and selling of the software. The license includes a 2024 copyright notice attributed to Hootan Hemmati and specifies that the software is provided "as is" without any warranty, limiting the liability of the authors.
Updated CD.yml to enhance CI/CD:
- Trigger on tags matching `v*.*.*` and `pull_request`.
- Updated `actions/checkout` to `v4`.
- Added `build` job for macOS.
- Modified `create_nuget` and `run_test` jobs to depend on `build`.
- Changed `deploy` and `create_github_release` to trigger on tag pushes.
- Simplified `create_github_release` job.

Updated PersianDate.csproj:
- Reformatted `Description`.
- Corrected `PackageProjectUrl`.
- Updated `Version` to `1.7.0`.
- Added `VersionPrefix` and `VersionSuffix`.

Fixed syntax in global.json.
@hootanht hootanht merged commit 0d847e0 into master Oct 3, 2024
7 checks passed
hootanht added a commit that referenced this pull request Oct 3, 2024
Merge pull request #27 from hootanht/develop
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.

1 participant