Config.TimeZone Property

Gets or sets the time zone.

Namespace: Gamanet.C4.SDK
Assembly: Gamanet.C4.SimpleClient (in Gamanet.C4.SimpleClient.dll) Version: 2026.0.0.733
Syntax
C#
public TimeZoneInfo TimeZone { get; set; }

Property Value

TimeZoneInfo

Implements

ISimpleClientConfigV1.TimeZone
Example
C#
using Gamanet.C4.SDK;
using Gamanet.C4.SimpleInterfaces;
using System;

public class TimeZoneGet 
{
    public void Main()
    {
        // create instance of simple client
        var client = new SimpleClient("HttpClient");

        string token;

        // connect to local server
        var connectionResult = client.Connect(new Uri("https://localhost/"), "Support", "support1", out token);

        if (connectionResult != ConnectionResult.Successful)
        {
            Console.WriteLine("Connection unsuccessful, result: {0}", connectionResult);

            return;
        }

        Console.WriteLine("Connection result: {0}", connectionResult);
        Console.WriteLine();

        var currentTimeZoneId = client.Config.TimeZone.Id;

        Console.WriteLine("Current time zone id:");
        Console.WriteLine(currentTimeZoneId);

        // The example displays the following output:
        // Connection result: Successful

        // Current time zone id:
        // UTC
    }
}
C#
using Gamanet.C4.SDK;
using Gamanet.C4.SimpleInterfaces;
using System;

public class ChangeTimeZone
{
    public void Main()
    {
        // create instance of simple client
        var client = new SimpleClient("HttpClient", null);string token;

        // connect to local server
        var connectionResult = client.Connect(new Uri("https://localhost/"), "Support", "support1", out token);

        if (connectionResult != ConnectionResult.Successful)
        {
            Console.WriteLine("Connection unsuccessful, result: {0}", connectionResult);

            return;
        }

        Console.WriteLine("Connection result: {0}", connectionResult);
        Console.WriteLine();

        var timeZoneIdBeforeChanging = client.Config.TimeZone.Id;

        Console.WriteLine("Time zone id before changing:");
        Console.WriteLine(timeZoneIdBeforeChanging);

        // change time zone by id
        client.Config.TimeZone = TimeZoneInfo.FindSystemTimeZoneById("Atlantic Standard Time");

        Console.WriteLine("Current time zone id:");
        Console.WriteLine(client.Config.TimeZone.Id);
        }

        // change time zone by id
        client.Config.TimeZone = TimeZoneInfo.FindSystemTimeZoneById(userTimeZoneId);
        Console.WriteLine("Current time zone id:");
        Console.WriteLine(client.Config.TimeZone.Id);

        // Connection result: Successful

        // Time zone id before changing:
        // UTC

        // Current time zone id:
        // Atlantic Standard Time
    }
}
C#
using Gamanet.C4.SDK;
using Gamanet.C4.SimpleInterfaces;
using System;
using Gamanet.C4.SDK.Enums;

public class WorkingPrinciple
{
    public void Main()
    {
        // create instance of simple client
        var client = new SimpleClient("HttpClient", null);string token;

        // connect to local server
        var connectionResult = client.Connect(new Uri("https://localhost/"), "Support", "support1", out token);

        if (connectionResult != ConnectionResult.Successful)
        {
            Console.WriteLine("Connection unsuccessful, result: {0}", connectionResult);

            return;
        }

        Console.WriteLine("Connection result: {0}", connectionResult);
        Console.WriteLine();

        var timeZoneIdBeforeChanging = client.Config.TimeZone.Id;

        var person = new SimplePerson(Guid.NewGuid(), "Bob", EntityRoot.Person, PersonCategory.Person);
        person.Data["Name"] = "Bob";
        person.Data["ValidFrom"] = DateTime.SpecifyKind(DateTime.Parse("1/1/2017 08:00:00"), DateTimeKind.Utc);
        client.Persons.Create(person);

        Console.WriteLine("Time zone id before changing:");
        Console.WriteLine(timeZoneIdBeforeChanging);

        var loadedPerson1 = client.Persons.Get(person.Id);

        Console.WriteLine("Time of data of person in current time zone format:");
        Console.WriteLine(loadedPerson1.Data["ValidFrom"]);

        Console.WriteLine();

        // change time zone by id
        client.Config.TimeZone = TimeZoneInfo.FindSystemTimeZoneById("Atlantic Standard Time");

        Console.WriteLine("Current time zone id:");

        var currentTimeZoneId = client.Config.TimeZone.Id;
        Console.WriteLine(currentTimeZoneId);

        var loadedPerson2 = client.Persons.Get(person.Id);

        Console.WriteLine("Time of data of person in updated time zone format:");
        Console.WriteLine(loadedPerson2.Data["ValidFrom"]);

        // The example displays the following output:
        // Connection result: Successful

        // Time zone id before changing:
        // UTC
        // Time of data of person in current time zone format:
        // 1 / 1 / 2017 8:00:00 AM

        // Current time zone id:
        // Atlantic Standard Time
        // Time of data of person in updated time zone format:
        // 1 / 1 / 2017 4:00:00 AM
    }
}
C#
using Gamanet.C4.SDK;
using Gamanet.C4.SimpleInterfaces;
using System;
using Gamanet.C4.SDK.Enums;

public class Validations
{
    public void Main()
    {
        // create instance of simple clientvar client = new SimpleClient("HttpClient", null);

        string token;
        // connect to local servervar connectionResult = client.Connect(new Uri("https://localhost/"), "Support", "support1", out token);

        if (connectionResult != ConnectionResult.Successful)
        {
            Console.WriteLine("Connection unsuccessful, result: {0}", connectionResult);

            return;
        }

        Console.WriteLine("Connection result: {0}", connectionResult);
        Console.WriteLine();

        var timeZoneIdBeforeChanging = client.Config.TimeZone.Id;

        Console.WriteLine("Time zone id before changing:");
        Console.WriteLine(timeZoneIdBeforeChanging);

        // create person with wrong datetime kind of datetime of data to get throw validation exception
        var person1 = new SimplePerson(Guid.NewGuid(), "Bob", EntityRoot.Person, PersonCategory.Person);
        person1.Data["Name"] = "Bob";
        person1.Data["ValidFrom"] = DateTime.SpecifyKind(DateTime.Parse("1/1/2017 08:00:00"), DateTimeKind.Unspecified);

        try
        {
            client.Persons.Create(person1);
        }
        catch (Exception e)
        {
            Console.WriteLine();
            Console.WriteLine("Exception:");
            Console.WriteLine(e.Message);
        }

        Console.WriteLine();

        // change time zone by id
        client.Config.TimeZone = TimeZoneInfo.FindSystemTimeZoneById("Atlantic Standard Time");

        Console.WriteLine("Current time zone id:");

        var currentTimeZoneId = client.Config.TimeZone.Id;
        Console.WriteLine(currentTimeZoneId);

        // create person with UTC datetime kind of datetime of data to get throw validation exception
        var person2 = new SimplePerson(Guid.NewGuid(), "Bill", EntityRoot.Person, PersonCategory.Person);
        person2.Data["Name"] = "Bill";
        person2.Data["ValidFrom"] = DateTime.SpecifyKind(DateTime.Parse("1/1/2017 08:00:00"), DateTimeKind.Utc);

        try
        {
            client.Persons.Create(person2);
        }
        catch (Exception e)
        {
            Console.WriteLine();
            Console.WriteLine("Exception:");
            Console.WriteLine(e.Message);
        }

        // The example displays the following output:
        // Connection result: Successful

        // Time zone id before changing:
        // UTC
        // Exception:
        // It is not possible to process current operation, because the supplied DateTime did not have the Kind property set correctly.
        // For example, when the Kind property is DateTimeKind.Utc, the client time zone must be TimeZoneInfo.Utc.

        // Current time zone id:
        // Atlantic Standard Time

        // Exception:
        // It is not possible to process current operation, because the supplied DateTime did not have the Kind property set correctly.
        // For example, when the Kind property is DateTimeKind.Utc, the client time zone must be TimeZoneInfo.Utc.
    }
}
See Also

Reference

Config Class
Gamanet.C4.SDK Namespace