Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/faisalman/time-cs
Time.cs - C# extension methods for DateTime to calculate relative time and age
https://github.com/faisalman/time-cs
c-sharp datetime-library extension-methods
Last synced: about 1 month ago
JSON representation
Time.cs - C# extension methods for DateTime to calculate relative time and age
- Host: GitHub
- URL: https://github.com/faisalman/time-cs
- Owner: faisalman
- Created: 2013-03-07T12:36:52.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-03-11T15:13:39.000Z (over 11 years ago)
- Last Synced: 2024-06-24T00:21:28.677Z (5 months ago)
- Topics: c-sharp, datetime-library, extension-methods
- Language: C#
- Homepage: http://faisalman.github.com/time-cs
- Size: 215 KB
- Stars: 2
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Time.cs
Extended C# DateTime Library
## Example
```cs
using System;
using Faisalman.Utils;class Program
{
static void Main(string[] args)
{
DateTime d1 = DateTime.Now;
DateTime d2 = d1.AddSeconds(30);
DateTime d3 = new DateTime(1970, 8, 21);
DateTime d4 = new DateTime(2014, 4, 30);// As DateTime extension method
Console.WriteLine(d2.GetRelativeTime(d1)); // output: "about 30 seconds ago"
Console.WriteLine(d1.GetRelativeTime(d2)); // output: "in about 30 seconds"
// As usual static method
Console.WriteLine(Time.GetRelativeTime(d2, d1)); // output: "about 30 seconds ago"
Console.WriteLine(Time.GetRelativeTime(d1, d2)); // output: "in about 30 seconds"Console.WriteLine(Time.GetAge(d3, d4)); // output: "43 years 8 months 9 days";
Console.ReadLine();
}
}
```## License
MIT License
Copyright © 2013 Faisalman <>