Getting current timezone name in Delphi - delphi

How can I get the current timezone name in Delphi ?
I mean, not the timezoneinfo, that I get via "getTimeZoneInformation"
but the name (as defined in the registry) of the current timezone,
that is, the current subkey of hklm\software\microsoft\windows nt\currentversion\timezones ?
Regards
Maurizio

Related

outlook-web-addin - Outlook calendar event start/end property depends on the selected timezone?

I am building an outlook addin which is active during compose/edit of an outlook calendar event. The addin accesses the start/end time of the event with the apis described
here. This yields a Time object, described here, on which I use getAsync() to get a Date object.
According to my interpretation of the documentation about the start property, the "result" argument of the callback called by getAsync() should be a time expressed as UTC, but this is not the case (it is expressed in local time).
But this, as far as I understand, is a javascript Date peculiarity, and I can handle it. The real problem I have is that outlook 365 allows to select a timezone in the event creation form, as can be seen here.
When I change the timezone, accessing the start property from the addin results in a different time (which is also expressed in local time). I would expect the same time (as before selecting a different timezone). Looking at the event created by Outlook in the calendar, it is also clear that Outlook does know it is the same time, expressed in a different timezone.
So, to make this more concrete:
create a new event in the calendar which for example starts at 11:30 and ends at 13:00 (selected timezone in compose form is local time, for example "Brussels Copenhagen Madrid, UTC + 1")
when accessing the start property from the addin, we get a Date object which contains "11:30 UTC + 1" (for a user located in this timezone)
now we change the timezone in the form, to "Moscow, St. Petersburg, Volgograd, UTC + 3".
when reading the start property, we now get a Date object which contains "13:30 UTC + 1", but we expect the same "10:30 UTC" or maybe "11:30 UTC + 1". The reason we expect this to be the same is that changing the timezone in which the time is expressed should not move the event in time. And actually outlook does not move the event (as can be seen in the calendar), but the start property is telling us that it does.
I'm aware of the Office.context.mailbox.convertUtcClientTime() and Office.context.mailbox.convertToLocalClientTime() methods but, as far as I understand and can test, I can not use those to get what I want.
So my question is: did I misunderstand something or am I doing something wrong, and if so, how do I get the real time at which the event starts/ends (in UTC preferably), but not depending on the selected timezone ?
Edit: This behaviour has been observed on Outlook desktop version (version 1901 click-to-run monthly channel, running on windows 10) and also with Outlook on the web (https://outlook.office365.com/) on multiple web platforms. Our manifest.xml file for the add-in contains the following section
<Hosts>
<Host Name="Mailbox" />
</Hosts>
<Requirements>
<Sets>
<Set Name="Mailbox" MinVersion="1.1" />
</Sets>
</Requirements>
The index.html file of the addin contains the following:
<script type="text/javascript"
src="https://appsforoffice.microsoft.com/lib/1/hosted/Office.js">
</script>

How to prevent to change value DateTime object from Utc time zone to WebApplication user timezone in Kendo-UI MVC

I'm facing one issue in my MVC application. In one module I'm using kendo-ui grid (Ex. #(Html.Kendo().Grid(Model))). Issue is, its change the DateTime object value when it render on the web browser. Ex. If my DateTimeobject value on server side is '2016-09-20 00:00:00' and when it renders on the browser then this value becomes '2016-09-20 05:30:00' (India time zone +5:30), on client side rendering DateTime object value add the time zone value of the user's browser. so my DateTime object value is changed and I do not want to change it. Is there any solution available for this kind of problems?
The date values are changed by the browser, because JavaScript Date objects are represented in the local time zone. The workaround is to use UTC:
http://docs.telerik.com/kendo-ui/aspnet-mvc/helpers/grid/how-to/utc-time-on-both-server-and-client

How to save utc from the manually selected datetime in azure web app?

In my project i saving the selected datetime(in UTC) from my datepicker.It saves the utc datetime only while application running in local.After deploying to azure it saves the selected datetime from datepicker irrespective of utc.
Update :
string selecteddate = "12/04/2016 05:30:15";
DateTime dt = Convert.ToDateTime(selecteddate).ToUniversalTime();
this code saves utc datetime in db in localhost,But it not working in azure
The DateTime instance you create with Convert.ToDateTime(selecteddate) will have DateTimeKind.Unspecified. Because of this, when you then call ToUniversalTime, it is making the assumption that the source value is in the local time zone of the computer where the code is running.
On Azure, that time zone is already UTC, so while the .Kind will change to DateTimeKind.Utc, the value will stay the same.
If you intended it to be converted from a particular time zone, then use TimeZoneInfo.ConvertTimeToUtc instead, passing a specific TimeZoneInfo value for the time zone you care about.
In general, don't rely on the local time zone setting in a web app, as the time zone could be different depending on where you deploy. Avoid ToUniversalTime and ToLocalTime, as well as DateTime.Now and other functions that depend on the local machine's time zone setting.

Check if cxDateEdit is entered in the right format

Maybe trivial but .... How do you check if the user has written the right date (in the right format) inside the cxDateEdit ? I know he can select a date with a mouse but just in case he tries to manually enter one, how can you correct his mistake if he/she writes a wrong date ?
A cxDateEdit will not post an invalid date. If you have special requirements as what is a valid date then use the Properties.OnValidate event to reject a date you don't like by setting the Error var to true;
How do you check if the user has written the right date (in the right format) inside the cxDateEdit?
There's no need: providing a string which specifies a format for the TcxDateEdit.Properties.EditFormat property, the input must match the format.
See System.SysUtils.FormatDateTime#Description for a list of the available specifiers.

CSOM Sharepoint current user timezone

I need to get the TimeZone and its Bias for the current user in CSOM.
If I read the siteuserinfolist for my current user, I get a TimeZone field with a ushort ID.
is SSOM, I can use SPRegionalSettings with this ID
is CSOM, TimeZoneInfo.GetSystemTimeZones uses a String ID (like the timezone title !)
Any idea how I can get the Bias of the current user in CSOM ?
THANKS !

Resources