Solved

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

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
daypilot scheduler 3 26
ASP.net VB.net Errors when sending data to SQL 5 20
Output Caching in IIS 2 28
Need help with building query string 2 19
You can provide a virtual interface for remote stakeholders in a SWOT analysis through a Google Drawing template. By making real time viewing and collaboration possible, your team can build a stronger product.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This Micro Tutorial will demonstrate without sampling how to find out top organic landing pages. The hack gets around the standard way to find the pages in Google Analytics results in sampling for larger sites.
This Micro Tutorial demonstrates how to create custom reports and the secrets of determine the metrics and dimensions for your data that works best with your needs.

815 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

13 Experts available now in Live!

Get 1:1 Help Now