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
, useApp.TimeInfo.Now
instead to get the current application time !- Do NOT use
TimeZoneInfo.LOCAL
, useApp.TimeInfo.TZInfo
instead to get the application timeTimeZoneInfo
- 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
meansDateTime
value is in application time which is notTimeZoneInfo.LOCAL
DateTimeKind.Local
meansDateTime
value is inTimeZoneInfo.LOCAL
(e.g. it has been obtained withDateTime.Now
)DateTimeKind.Utc
onlyDateTime
values of this kind are assumed in UTC.
Properties
Now
Current time in application time-zone
DateTime Now { get; }
Property Value
TZinfo
Current time in application time-zone
TimeZoneInfo TZinfo { get; }
Property Value
Methods
ToAppTime(DateTime)
Convert a UTC dt
into application time-zone DateTime.
DateTime ToAppTime(DateTime dt)
Parameters
dt
DateTime
Returns
ToUtc(DateTime)
Convert application time-zone dt
into a UTC DateTime.
DateTime ToUtc(DateTime dt)
Parameters
dt
DateTime