Show / Hide Table of Contents

Class DateTimeExtensions

Provides extension methods for DateTime.

Inheritance
object
DateTimeExtensions
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Sartorius.SAF.Extensions
Assembly: Sartorius.SAF.dll
Syntax
public static class DateTimeExtensions

Methods

View Source

RoundToPrecision(DateTime, int)

Rounds to the given count of decimals. e.g. 2 will round to 1/100th second.

Declaration
public static DateTime RoundToPrecision(this DateTime value, int decimals)
Parameters
Type Name Description
DateTime value

The value.

int decimals

The decimals.

Returns
Type Description
DateTime
Examples

The following example rounds a datetime to 1/100th (2 decimals) of a second.

View Source

RoundToTicks(DateTime, long)

Rounds to the specified ticks.

Declaration
public static DateTime RoundToTicks(this DateTime value, long precision)
Parameters
Type Name Description
DateTime value

The value.

long precision

The tick precision.

Returns
Type Description
DateTime
Examples

The following example rounds a datetime to full days by using TicksPerDay.

Exceptions
Type Condition
ArgumentOutOfRangeException

precision;precisions must be greater than 0.

  • View Source
Back to top Generated by DocFX