{"id":30025108,"url":"https://github.com/ubf21/vali-time","last_synced_at":"2026-02-18T13:37:06.600Z","repository":{"id":287279626,"uuid":"964184080","full_name":"UBF21/Vali-Time","owner":"UBF21","description":"A lightweight .NET library designed to simplify time unit conversions and management. Whether you're working with milliseconds, seconds, minutes, or hours, Vali-Time provides a fluent and intuitive API to convert times.","archived":false,"fork":false,"pushed_at":"2025-04-10T23:52:00.000Z","size":26,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-22T05:58:15.698Z","etag":null,"topics":["converter","csharp","lib","library","nuget","nuget-package","time"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/UBF21.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null}},"created_at":"2025-04-10T20:21:23.000Z","updated_at":"2025-04-11T20:10:40.000Z","dependencies_parsed_at":"2025-04-10T22:40:42.479Z","dependency_job_id":null,"html_url":"https://github.com/UBF21/Vali-Time","commit_stats":null,"previous_names":["ubf21/vali-time"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/UBF21/Vali-Time","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UBF21%2FVali-Time","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UBF21%2FVali-Time/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UBF21%2FVali-Time/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UBF21%2FVali-Time/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/UBF21","download_url":"https://codeload.github.com/UBF21/Vali-Time/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UBF21%2FVali-Time/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269042263,"owners_count":24349655,"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","status":"online","status_checked_at":"2025-08-06T02:00:09.910Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["converter","csharp","lib","library","nuget","nuget-package","time"],"created_at":"2025-08-06T08:01:23.190Z","updated_at":"2026-02-18T13:37:01.577Z","avatar_url":"https://github.com/UBF21.png","language":"C#","funding_links":["https://paypal.me/felipeRMM?country.x=PE\u0026locale.x=es_XC"],"categories":[],"sub_categories":[],"readme":"# \u003cimg src=\"https://github.com/UBF21/Vali-Time/blob/main/Vali-Time/logo-Vali-Time.png?raw=true\" alt=\"Logo de Vali Time\" style=\"width: 46px; height: 46px; max-width: 300px;\"\u003e Vali-Time - Time Unit Conversion and Management for .NET\n\n\n## Introduction 🚀\n\nWelcome to Vali-Time, a lightweight .NET library designed to simplify time unit conversions and management. Whether you're working with milliseconds, seconds, minutes, or hours, Vali-Time provides a fluent and intuitive API to convert times, sum multiple values, break down times into components, and format them into human-readable strings. With automatic unit detection and cultural formatting support, this library is perfect for applications requiring accurate time handling and integrates seamlessly into any .NET project.\n\n## Installation 📦\n\nTo add **Vali-Time** to your .NET project, install it via NuGet with the following command:\n\n```sh\ndotnet add package Vali-Time\n```\n\nEnsure your project targets a compatible .NET version (e.g., .NET Standard 2.0 or later). Vali-Time is lightweight and has minimal dependencies, making it an easy addition to your application.\n\n## Usage 🛠️\n\nVali-Time focuses on converting time between units, summing times, breaking them down, and formatting them for display. The library provides a simple class, TimeConverter, with methods to perform these operations with precision and flexibility.\n\n### Basic Example\n\nHere’s how you can convert and format a time value:\n\n```csharp\nusing Vali_Time.Converters;\nusing Vali_Time.Enums;\n\nvar converter = new TimeConverter();\n\n// Convert 1.5 hours to seconds\ndecimal seconds = converter.Convert(1.5m, TimeUnit.Hours, TimeUnit.Seconds);\nConsole.WriteLine(seconds); // Outputs: 5400\n\n// Format a time in minutes\nstring formattedTime = converter.FormatTime(123.456m, TimeUnit.Minutes);\nConsole.WriteLine(formattedTime); // Outputs: \"123.46 min\"\n```\n\n## Key Methods 📝\n\n**Vali-Time** offers a straightforward API for time management. Below are the key methods provided by the **TimeConverter** class:\n\n### Convert 🏗️\n\nConverts a file size from one unit to another with precision:\n\n```csharp\nvar converter = new TimeConverter();\n\n// Convert 2.5 minutes to seconds with 2 decimal places\ndecimal seconds = converter.Convert(2.5m, TimeUnit.Minutes, TimeUnit.Seconds, decimalPlaces: 2);\nConsole.WriteLine(seconds); // Outputs: 150.00\n```\n### SumTimes 🎨\n\nSums multiple time values in different units and returns the result in a specified unit:\n\n```csharp\nvar converter = new ValiFileSize();\n\n// Format 1,234,567 bytes as megabytes\nstring formatted = converter.FormatSize(1234567, FileSizeUnit.Megabytes, decimalPlaces: 3);\nConsole.WriteLine(formatted); // Outputs: \"1.177 MB\"\n```\n### FormatTime 🎨\n\nFormats a time value into a human-readable string with customizable decimal places and cultural formatting:\n\n```csharp\nvar converter = new TimeConverter();\n\n// Format 1234.567 seconds as minutes\nstring formatted = converter.FormatTime(1234.567m, TimeUnit.Minutes, decimalPlaces: 3);\nConsole.WriteLine(formatted); // Outputs: \"20.576 min\"\n```\n\n### GetBestUnit 🔍\n\nAutomatically determines the most appropriate unit for a given time in seconds:\n\n```csharp\nvar converter = new TimeConverter();\n\n// Find the best unit for 7200 seconds\nvar (time, unit) = converter.GetBestUnit(7200m);\nstring bestFormat = converter.FormatTime(time, unit);\nConsole.WriteLine(bestFormat); // Outputs: \"2.00 h\"\n```\n\n### Breakdown 🧩\n\nBreaks down a time in seconds into a dictionary of units (hours, minutes, seconds, milliseconds):\n\n```csharp\nvar converter = new TimeConverter();\n\n// Breakdown 3665.678 seconds\nvar breakdown = converter.Breakdown(3665.678m);\nConsole.WriteLine($\"{breakdown[TimeUnit.Hours]}h {breakdown[TimeUnit.Minutes]}m {breakdown[TimeUnit.Seconds]}s {breakdown[TimeUnit.Milliseconds]}ms\");\n// Outputs: \"1h 1m 5s 678ms\"\n```\n\n## Working with Advanced Features 🧩\n\n**Vali-Time** supports advanced use cases like cultural formatting and precise time management:\n\n### Cultural Formatting\n\nFormat times according to specific cultures:\n\n```csharp\nusing System.Globalization;\n\nvar converter = new TimeConverter();\nvar germanCulture = new CultureInfo(\"de-DE\");\n\nstring formatted = converter.FormatTime(1234.567m, TimeUnit.Seconds, 2, germanCulture);\nConsole.WriteLine(formatted); // Outputs: \"1234,57 s\" (uses comma as decimal separator)\n```\n\n### Combining Features\n\nConvert, sum, and format times in one flow:\n\n```csharp\nvar converter = new TimeConverter();\nvar times = new (decimal, TimeUnit)[]\n{\n    (1.5m, TimeUnit.Hours),\n    (30m, TimeUnit.Minutes)\n};\ndecimal totalSeconds = converter.Add(TimeUnit.Seconds, times);\nvar (bestTime, bestUnit) = converter.GetBestUnit(totalSeconds);\nstring result = converter.FormatTime(bestTime, bestUnit);\nConsole.WriteLine(result); // Outputs: \"2.00 h\"\n```\n\n## Comparison: Without vs. With Vali-FileSize ⚖️\n\n### Without Vali-Time (Manual Conversion)\n\nManually handling time conversions can be error-prone and cumbersome:\n\n```csharp\ndecimal hours = 1.5m;\ndecimal seconds = hours * 3600;\ndecimal totalSeconds = seconds + (30m * 60);\nConsole.WriteLine($\"{totalSeconds:F2} s\"); // Outputs: \"7200.00 s\"\n```\n\n### With Vali-Time (Simplified Conversion)\n\n**Vali-Time** streamlines the process with a clean and precise API:\n\n```csharp\nvar converter = new TimeConverter();\nvar times = new List\u003c(decimal, TimeUnit)\u003e()\n{\n    (1.5m, TimeUnit.Hours),\n    (30m, TimeUnit.Minutes)\n};\ndecimal totalSeconds = converter.Add(TimeUnit.Seconds, times);\nstring formatted = converter.FormatTime(totalSeconds, TimeUnit.Seconds);\nConsole.WriteLine(formatted); // Outputs: \"7200.00 s\"\n```\n## Features and Enhancements 🌟\n\n### Recent Updates\n\n- Initial release (v1.0.0) with support for conversions across milliseconds, seconds, minutes, and hours.\n-Added (or SumTimes) for summing multiple time values with precision.\n- Introduced Breakdown for decomposing time into detailed components..\n- Included FormatTime with customizable decimal precision and cultural support.\n- Ensured robust validation with negative time checks and comprehensive exception handling.\n\n### Planned Features\n\n- Support for additional units like days, weeks, and months.\n- Enhanced formatting options, such as combined unit strings (e.g., \"1h 30min 45s\").\n- Integration with **TimeSpan** for broader compatibility.\n\nFollow the project on GitHub for updates on new features and improvements!\n\n## Donations 💖\n\nIf you find ***Vali-Time*** useful and would like to support its development, consider making a donation:\n\n- **For Latin America**: [Donate via MercadoPago](https://link.mercadopago.com.pe/felipermm)\n- **For International Donations**: [Donate via PayPal](https://paypal.me/felipeRMM?country.x=PE\u0026locale.x=es_XC)\n\n\nYour contributions help keep this project alive and improve its development! 🚀\n\n## License 📜\nThis project is licensed under the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0).\n\n## Contributions 🤝\nFeel free to open issues and submit pull requests to improve this library!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fubf21%2Fvali-time","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fubf21%2Fvali-time","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fubf21%2Fvali-time/lists"}