Solved

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

Posted on 2011-09-02
1
563 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 500 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

There are many add-ons for Google docs, slides and sheets that can be extremely helpful in keeping your files organized and simple to use. Add-ons are installed into your Google docs, slides or sheets through Google's Add-On Store. One of my favorit…
If your app took Google’s lash recently, here are the 5 most likely reasons.
This Micro Tutorial demonstrates the importance of annotations in Google Analytics and how they should be used to document changes made to a site, Google updates (Ex: Panda & Penguin), marketing campaigns, and any other events that might have contri…
This Micro Tutorial demonstrates in Google Analytics how to create a custom report that shows you traffic over time using the month of year dimensions. There are also instructions on how to fix Google's odd month of year formatting, which Microsoft …

757 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now