{"id":24783445,"url":"https://github.com/j0rgeserran0/iso8601duration","last_synced_at":"2025-06-24T06:35:57.719Z","repository":{"id":81626472,"uuid":"114768972","full_name":"J0rgeSerran0/Iso8601Duration","owner":"J0rgeSerran0","description":"ISO 8601 :: C# library to convert a duration pattern in a TimeSpan object, a Custom object or to a Lexical Representation","archived":false,"fork":false,"pushed_at":"2019-11-22T07:25:43.000Z","size":21,"stargazers_count":8,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-05T08:03:54.060Z","etag":null,"topics":["8601","csharp","duration","iso","iso8601","netcore2","netframework"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/J0rgeSerran0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-12-19T13:34:37.000Z","updated_at":"2023-04-10T10:30:46.000Z","dependencies_parsed_at":"2023-04-24T20:16:50.546Z","dependency_job_id":null,"html_url":"https://github.com/J0rgeSerran0/Iso8601Duration","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/J0rgeSerran0%2FIso8601Duration","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/J0rgeSerran0%2FIso8601Duration/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/J0rgeSerran0%2FIso8601Duration/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/J0rgeSerran0%2FIso8601Duration/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/J0rgeSerran0","download_url":"https://codeload.github.com/J0rgeSerran0/Iso8601Duration/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":236176747,"owners_count":19107395,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["8601","csharp","duration","iso","iso8601","netcore2","netframework"],"created_at":"2025-01-29T12:17:09.543Z","updated_at":"2025-01-29T12:17:10.236Z","avatar_url":"https://github.com/J0rgeSerran0.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Iso8601Duration - C# Library\n\n\u003cimg src=\"https://docs.microsoft.com/es-es/dotnet/images/hub/csharp.svg\" alt=\"C#\" width=\"150\" height=\"150\" /\u003e\n\nISO 8601 :: C# library that converts Duration Patterns from the ISO 8601 and resolves limitations with the convertion with System.Xml.\n\nYou can find more information about the ISO 8601 and the lexical reprentation in the next link.\n[ISO 8601 - Lexical Representation - Duration](https://www.w3.org/TR/xmlschema-2/#duration)\n\nThe format of a lexical representation is:\n\u003e PnYnMnDTnHnMnS\n\n\n# NuGet - Iso8601Duration\n(Compatible for .NET Framework v4.6.1 or greater, and .NET Core 2.0 or greater)\n\n\u003cimg src=\"https://raw.githubusercontent.com/NuGet/Home/dev/resources/nuget.png\" alt=\"NuGet\" width=\"94\" height=\"29\" /\u003e\n\n[Iso8601Duration Converter - v1.0.0](https://www.nuget.org/packages/Iso8601Duration/)\n\n\n## Structs\n\n- [x] [`DurationStruct`](#durationstruct)\n\n\n### `DurationStruct`\n\n![Separator](/images/bullet_green.png) **`struct DurationStruct`** - Struct to work with dates and times easily.\n\n```csharp\npublic int Years;\npublic int Months;\npublic int Days;\npublic int Hours;\npublic int Minutes;\npublic int Seconds;\n\n```\n\n\n\n## Method's\n\n- [x] [`NormalizeDuration`](#normalizeduration)\n- [x] [`ToDurationStruct`](#todurationstruct)\n- [x] [`ToString`](#tostring)\n- [x] [`ToTimeSpan`](#totimespan)\n\n\n### `NormalizeDuration`\n\n![Separator](/images/bullet_green.png) **`string NormalizeDuration(string pattern)`** - Converts a general pattern in a correct and a well formed pattern.\n\n```csharp\n// \"PT61S\" to \"PT1M1S\"\nvar periodBuilder = new PeriodBuilder();\nvar pattern = \"PT61S\";\nvar wellFormedPattern = periodBuilder.NormalizeDuration(inputPattern);\n\n```\n\n\n### `ToDurationStruct`\n\n![Separator](/images/bullet_green.png) **`DurationStruct ToDurationStruct(TimeSpan timeSpan)`** - Converts from TimeSpan to DurationStruct.\n\n```csharp\nvar periodBuilder = new PeriodBuilder();\nvar durationStruct = periodBuilder.ToDurationStruct(new TimeSpan(0, 0, 120));\n\n```\n\n![Separator](/images/bullet_green.png) **`DurationStruct ToDurationStruct(string pattern)`** - Converts from TimeSpan to DurationStruct.\n\n```csharp\nvar periodBuilder = new PeriodBuilder();\nvar durationStruct = periodBuilder.ToDurationStruct(\"P1Y\");\n\n```\n\n\n### `ToString`\n\n![Separator](/images/bullet_green.png) **`string ToString(TimeSpan timeSpan)`** - Converts from TimeSpan to Duration Pattern.\n\n```csharp\nvar periodBuilder = new PeriodBuilder();\nvar durationStruct = periodBuilder.ToString(new TimeSpan(0, 120, 0));\n\n```\n\n![Separator](/images/bullet_green.png) **`string ToString(DurationStruct durationStruct)`** - Converts from DurationStruct to Duration Pattern.\n\n```csharp\nvar periodBuilder = new PeriodBuilder();\nvar durationStruct = periodBuilder.ToString(\"PT2H\");\n\n```\n\n\n### `ToTimeSpan`\n\n![Separator](/images/bullet_green.png) **`TimeSpan ToTimeSpan(string pattern)`** - Converts from Duration Pattern to TimeSpan.\n\n```csharp\nvar periodBuilder = new PeriodBuilder();\nvar durationStruct = periodBuilder.ToTimeSpan(\"PT2H\");\n\n```\n\n![Separator](/images/bullet_green.png) **`TimeSpan ToTimeSpan(DurationStruct durationStruct)`** - Converts from DurationStruct to TimeSpan.\n\n```csharp\nvar periodBuilder = new PeriodBuilder();\nvar durationStruct = periodBuilder.ToTimeSpan(new DurationStruct() { Minutes = 1440 });\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fj0rgeserran0%2Fiso8601duration","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fj0rgeserran0%2Fiso8601duration","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fj0rgeserran0%2Fiso8601duration/lists"}