473,799 Members | 3,214 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DateTime - parsing string with timezone in three letter acronyms

Hello,

Wondering, if C# (framework 2.0) does not support parsing DateTime timezones
in three letter acronyms.

I would like to parse date strings like "2005 Nov 01 11:58:47.490 CST -6:00"
but it seems C# does not support the timezone letters (CST). I suppose to
use the symbol ZZZ for the timezone letters, but MSDE [1] pointed out that
it is not supported in C#, isn't it?

Of course I can write my own methode for parsing this (using regex or a list
of timezones, etc.) but I want to ask if there is no "build-in" support in
the 2.0 framework?

Best Regards,
Michael Meckelein

[1] DateTimeFormatI nfo Class
http://msdn2.microsoft.com/en-us/lib...ormatinfo.aspx
Aug 14 '06 #1
4 6422
What exactly does that string mean? Is it -6 hours from UTC or -6 hours from
CST?
I'm guessing that you mean the time 11:58:47 CST, i.e. around noon somewhere
in the middle of the US? If so, the CST part is redundant since the timezone
offset (-6) is enough to know what time you're talking about.

Look into DateTime.TryPar seExact/ParseExact if you want to control exactly
how the parsing should be done.
/claes

"Michael Meckelein" <mi*****@go-on-line.dewrote in message
news:44******** *************** @newsspool4.arc or-online.net...
Hello,

Wondering, if C# (framework 2.0) does not support parsing DateTime
timezones in three letter acronyms.

I would like to parse date strings like "2005 Nov 01 11:58:47.490
CST -6:00" but it seems C# does not support the timezone letters (CST). I
suppose to use the symbol ZZZ for the timezone letters, but MSDE [1]
pointed out that it is not supported in C#, isn't it?

Of course I can write my own methode for parsing this (using regex or a
list of timezones, etc.) but I want to ask if there is no "build-in"
support in the 2.0 framework?

Best Regards,
Michael Meckelein

[1] DateTimeFormatI nfo Class
http://msdn2.microsoft.com/en-us/lib...ormatinfo.aspx

Aug 14 '06 #2
Hello claes,

Thank you for your reply.
What exactly does that string mean? Is it -6 hours from UTC or -6 hours
from CST?
I'm guessing that you mean the time 11:58:47 CST, i.e. around noon
somewhere in the middle of the US? If so, the CST part is redundant since
the timezone offset (-6) is enough to know what time you're talking about.
You are absolutely right. It is -6 hours from UTC. I did not know for what
reason Cisco use this redundancy. In fact this is CISCO IOS compatible log
format e.g. used by VPN Concentrator.
Look into DateTime.TryPar seExact/ParseExact if you want to control exactly
how the parsing should be done.
Actually this is what I did. But I am uncertain what string format to use
due to the missing timezone letters. Of course I can use string format "
yyyy MMM dd HH:mm:ss.fff CST z:00" for the given sample, however this does
not work in other timezones. As far as I see from the documentation there is
no placeholder for DateTime Format Strings such an ? or * as it is in regex.
So have I use regex in order to eliminate the timezone letters before I use
the DateTime.ParseE xact? Or do you have any better solution at hand?

Thanks,
Michael
Aug 14 '06 #3

"Michael Meckelein" <mi*****@go-on-line.dewrote in message
news:44******** *************** @newsspool2.arc or-online.net...
Hello claes,

Thank you for your reply.
>What exactly does that string mean? Is it -6 hours from UTC or -6 hours
from CST?
I'm guessing that you mean the time 11:58:47 CST, i.e. around noon
somewhere in the middle of the US? If so, the CST part is redundant since
the timezone offset (-6) is enough to know what time you're talking
about.

You are absolutely right. It is -6 hours from UTC. I did not know for what
reason Cisco use this redundancy. In fact this is CISCO IOS compatible log
format e.g. used by VPN Concentrator.
>Look into DateTime.TryPar seExact/ParseExact if you want to control
exactly how the parsing should be done.

Actually this is what I did. But I am uncertain what string format to use
due to the missing timezone letters. Of course I can use string format "
yyyy MMM dd HH:mm:ss.fff CST z:00" for the given sample, however this does
not work in other timezones. As far as I see from the documentation there
is no placeholder for DateTime Format Strings such an ? or * as it is in
regex. So have I use regex in order to eliminate the timezone letters
before I use the DateTime.ParseE xact? Or do you have any better solution
at hand?
That's the only solution I can think of. Guess it wouldn't hurt to ask Cisco
if they have some solution to convert it to a real date object. And while
you're at it, ask them what the hell they were thinking when the decided
upon that format :-)

/claes
Aug 15 '06 #4
>>[eliminate the timezone letters]
That's the only solution I can think of. Guess it wouldn't hurt to ask
Cisco if they have some solution to convert it to a real date object.
I will try it, but it is not quite easy to get in touch with them.
>And while you're at it, ask them what the hell they were thinking when the
decided upon that format :-)
I will do so if I get a chance ;)

Thanks for your thoughts.

Michael
Aug 15 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
5164
by: Symon R | last post by:
This is a bit of a weird one that I haven't yet been able to solve - I'm hoping someone out there can disprove my findings and tell me where I've gone wrong! I have designed a web service that accepts messages from .NET clients. The web method call includes an object as one of it's parameters - this reflected object has been given a property called "FutureDelivery" and expects a DateTime value. The clients may be in different timezones...
1
2784
by: Adam Monsen | last post by:
Say I have the following datetime object: >>> from datetime import datetime >>> d = datetime(2005, 8, 10, 15, 43) I happen to know this is a local time from the Netherlands, so I assume the tzinfo (if it were present) should indicate Central European Summer Time ("Summer" indicates daylight savings). How do I convert this date/time information to UTC?
2
14281
by: andrew lowe | last post by:
Hi, Please bear with me on this problem, first I'll give you some background: I have an object that contains a DateTime field which i pass to a webservice public class Foo { public DateTime RequestDate; }
0
1234
by: Kevin | last post by:
Greetings. I am using a myDataSet.WriteXml(StringWriter) function (and then using the ToString() function to convert it to a string) to build an XML string based on the contents of my dataset. This in itself works great. I am then passing this string back to a PowerBuilder module that is taking this XML string and doing what it needs to do with it. This is almost working great as well. It works fine for all datatypes except DateTime...
4
15246
by: GiriT | last post by:
Would appreciate some insight into how people are dealing with the implicit conversion of timezones that .NET does. If a server in one timezone delivers up a typed dataset to a component in another (winform for example) then the timezone conversion takes place. This is a pain if you are doing date based calculations on the client using input in one timezone and data from another. (Take one hour off a CET time and you go a day back in...
3
8341
by: asanford | last post by:
I want to create a web service that allows the caller to pass a DateTime to the web service (that is, create a web method such as void MyWebMethod(DateTime dt).) However, I want to be able to capture the TimeZone of the caller as well - but I don't want the interface to specify an xs:string as the method argument - I want it to use an xs:dateTime type argument. Now, I know when a DateTime structure is serialized into XML it becomes an...
9
9370
by: Abhishek | last post by:
Hi I am trying to deserialize/ Parse a datetime object with the below string "2007-05-14T08:00:00.000+02:30" . If i am in GMT + 2.30 time zone everything's fine however if i am in GMT + 5.30 i get the DateTime object which represents 11.00 AM. Now this is perfectly fine as if i go from GMT +2.30 tp GMT + 5.30 , 8.00 AM becomes 11.00 AM. however this is not what i want to achieve in my program. What i want to achieve is to reconstruct a...
4
3105
by: Rohit | last post by:
I am trying to get client machine's timezone from my java script . But i have no idea how would i be able to get it in uclibc format. (e.g. GMT+0IST-1,M3.5.0/01:00:00,M10.5.0/02:00:00) . I saw couple of posting on net from which suggest getTimezoneoffset or may be calculation with dates from script gives correct offset including day light saving time but i am not sure how correct this is. Again even if its correct , its not telling me...
2
3524
by: Richard Rossel | last post by:
Hi friends, I need a little help here, I 'm stuck with epoch calculation issue. I have this datetime: date_new = datetime(*time.strptime('20080101T000000','%Y%m%dT%H%M%S') ) This date_new is in UTC Now I need to know the seconds since epoch of this new date, so I run this: seconds = int(time.mktime(date_new.timetuple())) but the seconds returned belongs to :
0
9688
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9546
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10260
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10030
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9078
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7570
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6809
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.