473,378 Members | 1,500 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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] DateTimeFormatInfo Class
http://msdn2.microsoft.com/en-us/lib...ormatinfo.aspx
Aug 14 '06 #1
4 6374
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.TryParseExact/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.arcor-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] DateTimeFormatInfo 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.TryParseExact/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.ParseExact? 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.arcor-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.TryParseExact/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.ParseExact? 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
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...
1
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...
2
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...
0
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. ...
4
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...
3
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...
9
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...
4
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...
2
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.