Time Zone in Mobile Apps¶
This page will describe what you need to do to implement time zone for the mobile app.
Please read Time Zone Aware Development first, as most of the implementation of time zone is done on entity level and is the same for IFS Cloud Mobile as for IFS Cloud Web. It is a pre requisite.
The only changes that is specific to IFS Cloud Mobile is that you need to do some changes in the .offline files to make it available in the mobile app.
Time zone concept consist of the following two variants of time zone:
- Server time zone
- Site time zone
Note: The app client will always show the time in the device time zone, regardless if it is a server time zone entity or a site time zone entity. This is a bit different compared to IFS Cloud Web.
Server Time Zone¶
First of all, it's important to know that the Server Time Zone is not connected to the TimestampUTC.
With the server time zone, if a data source is annotated as server, it will save all of its timestamp values in UTC in the app client. In other words, all the transactions will be done in UTC.
With the server time zone, if a data source is annotated as server, the time zone used will be what is set in the server. All the records for this entity will have the same time zone. It will save all of its timestamp values in UTC in the app client and all the transactions will be done in UTC.
Example: If an entity A is annotated as server in all the online transactions, client will receive all of its timestamp values in UTC. Those values will also be saved as UTC.
.Offline file¶
In the .offline file, if you are doing a CRUD operation, please make sure that you treat all of its timestamp values as UTC.
@Override
procedure EntityPrepare<A> Structure(A) {
execute {
super(Record) into Record;
call DateTime.TimestampUtc() into Record.RegisterDate;
return Record;
}
}
Use DateTime.TimestampUtc(); instead of DateTime.Timestamp(); otherwise, the data will be corrupted.
Passing additional time zones¶
In the .offline
use EntityPrepare
in some instances the client file won't be able to pick the value from the projection this a limitation on the native client.
@Override
procedure EntityPrepare<A> Structure(A) {
execute {
super(Record) into Record;
call DateTime.TimestampUtc() into Record.RegisterDate;
set Record.FieldTimeZone = "Eastern Standard Time";
set Record.DialogTimeZone = "US Mountain Standard Time";
return Record;
}
}
Site Time Zone¶
With the site time zone, if a data source is annotated as site(Site), the time zone used will be what is set per site. Each record for this entity will have the time zone from the site. It will save all of its timestamp values in UTC in the app client and all the transactions will be done in UTC.
Example: If an entity A is annotated as site(Site) , client will receive the timestamp for each record of the entity in UTC. Those values will also be saved as UTC.
.Offline file¶
In the .offline file, if you are doing a CRUD operation, please make sure that you also add the variable for the site..
@Override
procedure EntityPrepare<A> Structure(A) {
execute {
super(Record) into Record;
call System.GetParameter("DefaultMpccomSite") into Record.Objsite;
return Record;
}
}
Passing additional time zones¶
Passing additional time zones for sites is the same as passing additional time zone, described above.
Operation Types¶
The following operation types exist as well as a comment what is needed for site time zone.
- Online
- CRUD needs Objsite for new records
- Bound Action - Nothing
- None Bound Action - Site Parameter should be present
- Functions - Site Parameter should be present
- Offline
- CRUD- needs Objsite for new records
- Bound Action - needs Objsite in the parameters
- None Bound Action - Objsite Parameter should be present
- Functions - N/A