TimeKit 1.0.0
dotnet add package TimeKit --version 1.0.0
NuGet\Install-Package TimeKit -Version 1.0.0
<PackageReference Include="TimeKit" Version="1.0.0" />
<PackageVersion Include="TimeKit" Version="1.0.0" />
<PackageReference Include="TimeKit" />
paket add TimeKit --version 1.0.0
#r "nuget: TimeKit, 1.0.0"
#:package TimeKit@1.0.0
#addin nuget:?package=TimeKit&version=1.0.0
#tool nuget:?package=TimeKit&version=1.0.0
TimeKit
TimeKit is a C# library for working with date and time values. It provides a set of utility methods for performing common operations such as parsing and formatting dates, calculating the difference between two dates, and converting between time zones. The library also includes support for the Hijri calendar and provides methods for working with business days and weeks.
Getting Started
To use TimeKit in your C# project, you can install it via NuGet. Open the NuGet Package Manager Console and run the following command:
Install-Package TimeKit
Once you have installed the package, you can start using the library in your code by adding the following using directive:
using TimeKit;
Examples
Here are some examples of using TimeKit:
// Parse a date string into a DateTime object
DateTime date = TimeUtils.Parse("2022-01-01");
// Format a DateTime object as a string using a specified format string
string formattedDate = TimeUtils.Format(date, "yyyy-MM-dd");
// Calculate the number of days between two DateTime objects
int daysApart = TimeUtils.GetDaysBetween(date, DateTime.Now);
// Convert a DateTime object to a specified time zone
DateTime convertedDate = TimeUtils.ConvertToTimeZone(date, "Pacific Standard Time");
// Calculate the number of months between two DateTime objects
int monthsApart = TimeUtils.GetMonthsBetween(date, DateTime.Now);
// Calculate the number of years between two DateTime objects
int yearsApart = TimeUtils.GetYearsBetween(date, DateTime.Now);
// Convert a Hijri date to a Gregorian date
DateTime hijriDate = TimeUtils.HijriToGregorian(1444, 5, 15);
// Convert a Gregorian date to a Hijri date
(int hijriYear, int hijriMonth, int hijriDay) = TimeUtils.GregorianToHijri(date);
// Check if a given year is a leap year in the Hijri calendar
bool isLeapYear = TimeUtils.IsHijriLeapYear(1444);
// Calculate the number of business days between two DateTime objects
int businessDays = TimeUtils.GetBusinessDaysBetween(date, DateTime.Now);
// Calculate the next occurrence of a specified day of the week
DateTime nextMonday = TimeUtils.GetNextDayOfWeek(date, DayOfWeek.Monday);
// Round a DateTime object to the nearest specified time interval
DateTime roundedDate = TimeUtils.RoundToNearestInterval(date, TimeSpan.FromMinutes(15));
// Calculate the number of days in a given month and year
int daysInMonth = TimeUtils.GetDaysInMonth(2022, 2);
// Calculate the number of days in a given year
int daysInYear = TimeUtils.GetDaysInYear(2022);
// Calculate the week number of a given date using a specified culture
CultureInfo culture = new CultureInfo("en-US");
int weekNumber = TimeUtils.GetWeekNumber(date, culture);
// Calculate the number of weeks in a given year using a specified culture
int weeksInYear = TimeUtils.GetWeeksInYear(2022, culture);
// Check if a given year is a leap year in the Gregorian calendar
bool isGregorianLeapYear = TimeUtils.IsGregorianLeapYear(2022);
Contributing
If you have found a bug or have a feature request, please open an issue on the GitHub repository. If you would like to contribute code, please fork the repository and submit a pull request.
License
TimeKit is released under the Apache License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net7.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 2,978 | 4/5/2023 |