Table of Contents

Interface IAppTime

Namespace
Tlabs
Assembly
Tlabs.Core.dll

Application time-zone specific time helper.

public interface IAppTime
Extension Methods

Remarks

This interface represents a notion of the application time.
All Tlabs Library functions that are dealing with time are using this object to coordinate time values between the application time and UTC. The application time (returned from IAppTime.Now) could be configured to be a time from any time-zone (default is UTC).

NOTE:

  • Time values stored in the persistent store should be assumed as in application time zone.
  • Do NOT use DateTime.Now, use App.TimeInfo.Now instead to get the current application time !
  • Do NOT use TimeZoneInfo.LOCAL, use App.TimeInfo.TZInfo instead to get the application time TimeZoneInfo
  • The application time is not necessarily equal to the local time of the operating system.
    (In some environments you might also do not have any control about the local time of a virtual machine's (cloud) operating system.)
  • Beware of the DateTime.Kind property !
    With the Tlabs application time it has following meanings:
    • DateTimeKind.Unspecified
      means DateTime value is in application time which is not TimeZoneInfo.LOCAL
    • DateTimeKind.Local
      means DateTime value is in TimeZoneInfo.LOCAL
      (e.g. it has been obtained with DateTime.Now)
    • DateTimeKind.Utc
      only DateTime values of this kind are assumed in UTC.

Properties

Now

Current time in application time-zone

DateTime Now { get; }

Property Value

DateTime

TZinfo

Current time in application time-zone

TimeZoneInfo TZinfo { get; }

Property Value

TimeZoneInfo

Methods

ToAppTime(DateTime)

Convert a UTC dt into application time-zone DateTime.

DateTime ToAppTime(DateTime dt)

Parameters

dt DateTime

Returns

DateTime

ToUtc(DateTime)

Convert application time-zone dt into a UTC DateTime.

DateTime ToUtc(DateTime dt)

Parameters

dt DateTime

Returns

DateTime