?
Solved

VB.Net GMT/UTC and server time (specifically Google Calendar)

Posted on 2011-09-02
1
Medium Priority
?
633 Views
Last Modified: 2014-11-12
Hi

I am linking  a web application to my Google calendar. The user can add events to their calendar using application.

I have a problem with the difference between GMT/UTC/BST and server time. Things work locally fine until it is hosted on remote server.

When the user inputs a new calendar entry, and clicks "OK" to make a new event, Google calendar (or somewhere between VB submitting the event and Google creating it) adds 6 or 7 hours (depending on if in BST or GMT/UTC)

e.g. if user inputs 6am on website, the value stored in Google calendar is made 12 or 1pm

In web.config (and pages) I have set <globalization uiCulture="en" culture="en-GB" />

See code for what is submitted to Google service.

NOTE: I also send an email to myself after creating event, using same properties, and it shows the USER INPUTTED Date/time - which is correct;
also, the results retrieved from Google calendar are correct for older appointments (both locally and on server)  are correct. When I make a new entry locally this works)

So the only problem is when creating an event on the SERVER.

Thanks in advance for help
Dim postUri As New Uri(CALENDAR_URI)
Dim calendarService = New CalendarService("JSCalendar")
calendarService.setUserCredentials("myuser", "mypassword")
Dim ev As New Google.GData.Calendar.EventEntry
ev.Title.Text = eventTitle
ev.Content.Content = content

' Set a location for the event. 
Dim eventLocation As New Where()
eventLocation.ValueString = location
ev.Locations.Add(eventLocation)
Dim eventTime As New [When](start, endTime)
ev.Times.Add(eventTime)

'write to service
ev = calendarService.Insert(postUri, ev)

Open in new window

0
Comment
Question by:rwallacej
1 Comment
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 2000 total points
ID: 36479720
I do not know the Google API, but usually, an application that expect to get times from everywhere around the world records it a UTC. Google knowing what they are doing, this is probably how they work.

The way to deal with date/times then, is to send the Universal Time to the server, something like the following:
start .ToUniversalTime

Open in new window


start is then adjusted to universal time according to the time zone set in your computer.

When you want to read back a time value from the server, you do the reverse. You convert the UTC value to the time zone of the receiving station:
start = dateFromServer.ToLocalTime

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Google is more than just a search engine. Over the years the company has developed a wide range of online services that are readily available to all users. This article highlights how one can use Google services for simple project management.
Many of you may be aware of the recent Google Docs scam emails that have been floating around coming from various people that you know. Here's a guide on identifying How To Identify the Scam Email You will see an email from someone you’ve had co…
This Micro Tutorial demonstrates how to quickly find related content for YourTango's posts using MozBar Chrome extension.
This Micro Tutorial will demonstrate common damaging and frequent mistakes I see in most analytic audits. Most of them are campaign tagging mistakes, so this video will break it down into simple steps.
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question