Time Zones Integration¶
The service provides a Client Module from which the clients can obtain the correct Date Time Offset, calculated with the current time zone.
Client Module¶
First register the client module:
XML | |
---|---|
Once the module is referenced, register it into the module dependencies:
C# | |
---|---|
Important
It is require to execute the migrations, since a new table is added where the client module store a copy of the time zone changes.
Banned Symbols¶
The DateTime.Now, DateTime.UtcNow and InVar.TimeStamp are now banned from use.
The client module provides a DateTime Provider, that is an abstraction of DateTime and returns the correct date calculated with the current time zone.
DateTime Provider¶
When the module is set, we can now use the DateTime Provider. It is an abstraction of DateTime that implements its own interface. It also makes it simpler to test its implementation.
It only requires to be injected where we need access to the Now value, and replace any DateTime.Now, DateTime.UtcNow or InVar.TimeStamp.
C# | |
---|---|
Time Zone Manager (API)¶
The service present and API for the services to use, that give access to two methods:
- GetCurrentTimeZone: return the current time zone stored in the client.
- GetTimeZoneByDate: return an specific time zone filtered by date.
To use this manager, only requires to inject the ITimeZoneManager in the code, and access either methods.
Entities that required a registered DateTime (ITimeZonedEntities)¶
The client provides an abstraction that automatically register the Created date time (in local DateTime) and the correspondent Offset.
For this the Application and Domain layer should reference the client module and implements the ITimeZonedEntity abstraction in the entity where the date is required. See the Client Module configuration at the beginning of this page.
C# | |
---|---|
A Repository Interceptor will later capture the entity creation and automatically set the Created and Offset values from the DateTimeProvider.
Important
It is require to execute the migrations, since the Created and Offset properties will be added to the entities table.
- Go to History Changed
- Back to Time Zones