Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7937439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:31:36+00:00 2026-06-03T22:31:36+00:00

I have read through multiple posts here until my head was ready to explode

  • 0

I have read through multiple posts here until my head was ready to explode with little lines on the atlas strewn all over.

Here is what I wanted to do:

  1. I have a calendar full of appointments to display for a business.
  2. The business is in New York (EDT)
  3. My dev machine is in PST
  4. Production Servers are in California (PST)
  5. Calendar data is stored in the DB in UTC

All I want to do is take a time range specified in EDT (say May 15, 9am – 5pm) and show all the appointments on the calendar.

So, my calendar control tells me “I want the appointments from 5/15/12 9am EDT – 5/15/12 5pm EDT”
I say fine, I will call a db proc and pass the date values in UTC, ie (5/15/12 13:00 UTC – 5/15/12 21:00 UTC). Then when I get them, I will convert them back to EDT before handing them to you.

However, Little did I know that .NET will find this simple task to trip me up.

I got the TimeZoneInfo just fine by using:

TimeZoneInfo zoneInfo = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time")

But that is as far as things worked.

Here’s what I tried next:

DateTime rangeStartUTC = TimeZoneInfo.ConvertTimeToUtc(rangeStart, zoneInfo);

EXCEPTION: Kind is not properly specified. 

(WTF is Kind?) I told you the time I want to convert, I told you it is in EDT, I told you I want to convert it to UTC. What more do you want? I could do it by hand. F**ing do it already.

So I tried to set the Kind, but it only has two values! Local or Utc. But my time is neither local, nor Utc. Why in the hell are you asking me for a time zone info then? Cant you just tell what the local time zone is by asking the system clock? Predictably, neither worked. (yeah, according to the docs there is UnSpecified, but again according to the docs, it doesn’t really do anything and yes I tried that one too).

Then, I tried:

TimeZoneInfo.ConvertTime(rangeStart, zoneInfo, TimeZoneInfo.Utc)

SAME LAME EXCUSE!

Time to read some more of St. Jon Skeet’s passages.

What do you know, there is a new class DateTimeOffset. It will solve all your problems.
God bless for all the nice and merciful .NET 4.0 bounties…

DateTimeOffset offStartTime = new DateTimeOffset(rangeStart, zone.GetUtcOffset(rangeStart));
rangeStartUTC = offStartTime.UtcDateTime;

EXCEPTION: "Offset should be 0 for Utc dates"

Gaaaaah!
How the heck did you conclude that the rangeStart is Utc? Did I ever tell you that?

A bunch of people are quoting
TimeZoneInfo.ConvertTime(rangeStart, zone) as the solution, how is it “Kind” enough to work for them? Unless their source time zone conveniently happens to be the same as their local time zone.

So what is a poor .NET C# developer to do?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T22:31:37+00:00Added an answer on June 3, 2026 at 10:31 pm

    Try DateTime.SpecifyKind(rangeStart, DateTimeKind.Unspecified) before DateTimeOffset or TimeZoneInfo. It should not do any conversion of the time itself, just change the Kind.

    As I understand it, the Kind on DateTime should be either Unspecified or correspond to the result of private TimeZoneInfo.GetCorrespondingKind() method, which returns Local for
    TimeZoneInfo.Local and Utc for TimeZoneInfo.Utc.

    UPDATE: Sorry, get the original answer wrong, should be all good now.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay guys, I have read through all the other posts and question on jQuery
I've read through the various posts on SO about this, but have still not
I have read through the Rails docs for Routing , Restful Resources , and
I have read through some tutorials about javascript prototypal inheritance patterns but I am
Ok, I'm programming in objective-C and using Xcode. I have read through the documentation
I'm trying to have my application read through a text file and look for
I've read through a number of topics now and have not found one quite
I have read the boost asio reference, gone through the tutorial and looked at
I have a web server which is protected behind http-basic-auth. I've read through the
First, thanks in advance for taking the time to read through this. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.