Docusign webhook callback TimeZoneOffset - docusignapi

I'm using Docusign's webhook event notification to get info about my envelopes. I'm getting XML back from the service, but I'm trying to convert some the timestamps in the XML payload to UTC. The XML payload includes a TimeZoneOffset as an element, i.e.:
<DocuSignEnvelopeInformation>
...
<TimeZoneOffset>-7</TimeZoneOffset>
</DocuSignEnvelopeInformation>
What happens if the offset is UTC? Is it just 0 or +0 or -0? Could it ever be something like +1030? Do positive values have + prepended?
How is this field determined anyway? Is it the last sender's timezone offset?

It is the account wide (or users) timezone. For example, I am in AEST which is UTC+10 and my XML comes through with:
<TimeZone>AUS Eastern Standard Time</TimeZone>
<TimeZoneOffset>10</TimeZoneOffset>
In Preferences --> Features if I change my API timezone to Pacific Time (US) then my offset changes to:
<TimeZone>Pacific Standard Time</TimeZone>
<TimeZoneOffset>-7</TimeZoneOffset>
It's based on UTC and the offset will be 'x' for UTC or ahead and '-x' for behind.

Related

ADF convertTimeZone Invalid Timezone ID

I encounter this weird issue related on using convertTimeZone function in ADF.
convertTimeZone function expect 4 params which are timestamp string, source timezone, new timezone, date format
Refer to this document [https://learn.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference#convertTimeZone]
I keep receiving error
the function 'convertTimeZone', the value provided for the time zone id 'Singapore Standard Time' was not valid. "
I double check it whether the timezone I provided is in the microsoft time zone list
Refer to this document: https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/default-time-zones?view=windows-11
Which in this case is in the list. Any thoughts?
Use the below expression to convert UTC to 'Singapore Standard Time' time zone.
#string(convertTimeZone(utcnow(), 'UTC','Singapore Standard Time'))
Output:
Reference: Microsoft Time Zone Index Value

Are Alexa skill dates the same in the Service Simulator and the Echo?

My Alexa node.js skill involves getting the current date using "new Date()". In the Service Simulator the date returned is UTC. But I need the time in "America/New_York" -- my skill is local to New York. So I can convert the time zone, no problem. But I'm wondering whether this will get the same result when I deploy the skill. That is, does the Date() function on the actual Service convert to local time from UTC? If it does, then I will need some way of determining in my code whether I am in the Service Simulator or the actual Service, and converting to New York time in my accordingly.
Thank you.
From the documentation for Date
If no arguments are provided, the constructor creates a JavaScript Date object for the current date and time according to system settings.
So depending on the system settings the timezones can be different.
To overcome this you can use UTC date everywhere and then simply convert the timezone where needed.
// date with some timezone depending on system
let date = new Date();
// date in UTC
let utcDate = new Date(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds());
Note: utcDate will still be in the system timezone, but the actual value it holds will represent the correct date and time in UTC.

how to get local timezone on azure service

I have a service running on azure cloud. This service runs in every 1 min and picks some files from ftp server. These files have Datetime fields and not datetimeoffset, which when read by service become UTC dates. These FTp servers are in different timezone.
For example one of the ftp is in GMT timezone. Say file has date 12/5/2015 time 12:15. This is read by service as UTC(because no timezone received) and stored in database as 12/5/2015: 12:15:00 +0:00, while it should be
12/5/2015: 11:15:00 +0:00.
I still want to save date in database as UTC, need a way to get these ftp timezones, so I can parse date correctly.
The problem is we can't make any changes in file.
Is there any way cloud sevice can get timezone for these FTP?
There's nothing Azure specific here for what you want, but you can roll your own solution.
You'd have to do some fancy stuff to guess the timezone of an FTP server, which would involve doing a DNS lookup of the server to figure out it's IP address, mapping that IP address to a city, and looking up the city's Time Zone. You could do that but it would be error prone.
There's an easier and more reliable option. It sounds like you your list of FTP servers is fairly static. You can just create a lookup table that says which timezone each FTP server is in, and use that table to figure out which timezone offset you should use.
Best practice: Server-side code should never depend on the time zone or culture settings of the server that is hosting the code. Instead, these concerns should be addressed in the code itself.
For example, assuming your service is written in C# / .NET, you might have code like this:
string s = "12/5/2015 12:15 PM"; // from the file
DateTime dt = DateTime.Parse(s);
DateTime utc = dt.ToUniversalTime();
The above code relies on the server's local time zone during the ToUniversalTime function. It also relies on the server's culture during the Parse function.
Instead, you should have knowledge of the time zone and culture of the input file. For example:
string s = "12/5/2015 12:15 PM"; // from the file
DateTime dt = DateTime.ParseExact(s, "M/d/yyyy h:mm tt", CultureInfo.InvariantCulture);
TimeZoneInfo tz = TimeZoneInfo.FindSystemTimeZoneById("Central Europe Standard Time");
DateTime utc = TimeZoneInfo.ConvertTimeToUtc(dt, tz);
This code supplies the CET/CEST time zone, and also provides an exact input format using the invariant culture.
Late post, but thought I would post my solution to help anyone else:
TimeZone localZone = TimeZone.CurrentTimeZone;
var cetZone = TimeZoneInfo.FindSystemTimeZoneById(localZone.StandardName);
var cetTime = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, cetZone);
DateCreated = Convert.ToDateTime(cetTime.ToString());
In my instance, the localZone.StandardName gives me "South African Standard Time", which I believe is GMT+2.
Hope this helps someone else out!
Cheers

Google Tasks Migration to Exchange account

I have retrieved Tasks from my Gmail account using OAuth 2.0 Dot Net Google client library (https://developers.google.com/api-client-library/dotnet/apis/tasks/v1). When I save any of these tasks to my exchange account using Microsoft.Exchange.WebServices Dot Net library, the date of Task is adjusted automatically, although the time zone of Gmail account and exchange account are same i.e. Central Time (US & Canada). I want to prevent this automatically adjustment in Task date.
Can any one help?
Make sure you set the time zone on the ExchangeService object to the user's time zone. https://msdn.microsoft.com/EN-US/library/office/dn789029(v=exchg.150).aspx
I have solved the problem by using Calendar time zone. Basically, Google Calendar has time zone information. I retrieved time zone information from primary calendar and then before saving Task to Exchange account, I converted due date to UTC with following C# code
if (task.Due.Value.Kind == DateTimeKind.Local)
{
dueDateUTC = task.Due.Value.ToUniversalTime();
unspecifiedKindDate = new DateTime(dueDateUTC.Year, dueDateUTC.Month, dueDateUTC.Day);
dueDateUTC = TimeZoneInfo.ConvertTime(unspecifiedKindDate, Utility.OlsonTimeZoneToTimeZoneInfo(timezone), TimeZoneInfo.Utc);
}
This code first of all find out that whether Task due date is in local time zone or not. If it is in local time zone then due date is converted into UTC. After converting into UTC, a unspecified kind datetime object is created through following code
unspecifiedKindDate = new DateTime(dueDateUTC.Year, dueDateUTC.Month, dueDateUTC.Day);
This unspecified kind datetime is then again converted to UTC with the help of following code
dueDateUTC = TimeZoneInfo.ConvertTime(unspecifiedKindDate, Utility.OlsonTimeZoneToTimeZoneInfo(timezone), TimeZoneInfo.Utc);
Now this "dueDateUTC" object is used to save Task information into Exchange account. On saving Task, Exchange server automatically converts dueDateUTC to mailbox time zone and this was desired. :)

Date timezone conversion socket.io

I'm writing a chat program using node.js and socket.io. When a user sends a message, I'd like the time at which they sent it to be emitted. Instead of the Date data being in the timezone of the person who sent it, however, I'd like it to be converted to the timezones of the respective recievers. Will JavaScript take care of this automatically, or is it something I need to fix?
socket.emit('chat', {
message: 'message',
date: new Date()
}
You can simply send the UTC value from the Date back to your server and up to another client. Even if they have different time zones, the local client will convert from the UTC value to that time zone when the Date is displayed.
It is important that the date is sent as UTC and not in the local time zone.
This can be an integer number (which will be milliseconds since 1/1/1970 UTC), obtained from .getTime(). All browsers support this, but it's not a very human readable format.
It can also be a string in ISO8601/RFC3339 format at UTC, such as 2013-06-26T15:40:00Z, which can be obtained by .toISOString().
What you can't do is just pass a Date object directly, as you showed in your sample. Socket.io will just call .toString() on it. That will end up sending a human readable RFC822 formatted string with the local time zone - not the UTC value that you want.
Javascript date object in different locale and timezone
This answer looks good. Store all your dates as UTC and then translate to receivers time zone.

Resources