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.Nowinstead to get the current application time !- Do NOT use
TimeZoneInfo.LOCAL, useApp.TimeInfo.TZInfoinstead 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.Kindproperty !
With the Tlabs application time it has following meanings:
DateTimeKind.Unspecified
meansDateTimevalue is in application time which is notTimeZoneInfo.LOCALDateTimeKind.Local
meansDateTimevalue is inTimeZoneInfo.LOCAL
(e.g. it has been obtained withDateTime.Now)DateTimeKind.Utc
onlyDateTimevalues 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
dtDateTime
Returns
ToUtc(DateTime)
Convert application time-zone dt into a UTC DateTime.
DateTime ToUtc(DateTime dt)
Parameters
dtDateTime