Enum TimeUnit
- Namespace
- Cuemon
- Assembly
- Cuemon.Core.dll
Specifies the unit of time - typically used with a TimeSpan.
public enum TimeUnit
Fields
Days = 0Indicates a time unit of Days.
Hours = 1Indicates a time unit of Hours.
Milliseconds = 4Indicates a time unit of Milliseconds.
Minutes = 2Indicates a time unit of Minutes.
Seconds = 3Indicates a time unit of Seconds.
Ticks = 5Indicates a time unit of Ticks, where one Tick is equal to 100 nanoseconds.
Examples
The following example demonstrates how to use the
using System;
using Cuemon; // for Decorator and ToTimeSpan
using Cuemon;
namespace MyApp.Examples;
public class TimeUnitExample
{
public void Demonstrate()
{
double value = 2.5;
TimeSpan days = Decorator.Enclose(value).ToTimeSpan(TimeUnit.Days);
Console.WriteLine(days); // 2.12:00:00
TimeSpan hours = Decorator.Enclose(value).ToTimeSpan(TimeUnit.Hours);
Console.WriteLine(hours); // 02:30:00
TimeSpan minutes = Decorator.Enclose(value).ToTimeSpan(TimeUnit.Minutes);
Console.WriteLine(minutes); // 00:02:30
TimeSpan seconds = Decorator.Enclose(value).ToTimeSpan(TimeUnit.Seconds);
Console.WriteLine(seconds); // 00:00:02.5000000
TimeSpan ticks = Decorator.Enclose(50000000.0).ToTimeSpan(TimeUnit.Ticks);
Console.WriteLine(ticks); // 00:00:05
}
}