Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Parsing string with Time Zone info

Parsing string with Time Zone info

Scheduled Pinned Locked Moved C / C++ / MFC
csharpc++jsonhelpquestion
2 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mike NET
    wrote on last edited by
    #1

    I tried using COleDateTime::ParseDateTime(...) and VarDateFromStr(...) to parse a date/time string that contains *time zone* information (ET, CT, +4:00, GMT+4:00, etc...) but every time I do so I get "Invalid DateTime" // code ////////////////////// COleDateTime dt; CString sdate = "Feb 1 2002 17:05 +7:00"; // <- Time Zone string date dt.ParseDateTime(sdate); CString st2 = dt.Format("%H:%M"); // <- returns 'Invalid DateTime' // ----------------------------- Is it just me (am I doing this wrong) or the ParseDateTime is no good for time zones? Is there any other way/method that could parse string with time zone information (like: "Feb 1 2002 17:05 +7:00"). JScript and VC#.NET have no problem parsing date/time strings with time zone info, but I can't seem to parse date/time string in VC++. :( Platform: WinXP Pro, VC++.NET (unmanaged) Thanks in advance Mike

    M 1 Reply Last reply
    0
    • M Mike NET

      I tried using COleDateTime::ParseDateTime(...) and VarDateFromStr(...) to parse a date/time string that contains *time zone* information (ET, CT, +4:00, GMT+4:00, etc...) but every time I do so I get "Invalid DateTime" // code ////////////////////// COleDateTime dt; CString sdate = "Feb 1 2002 17:05 +7:00"; // <- Time Zone string date dt.ParseDateTime(sdate); CString st2 = dt.Format("%H:%M"); // <- returns 'Invalid DateTime' // ----------------------------- Is it just me (am I doing this wrong) or the ParseDateTime is no good for time zones? Is there any other way/method that could parse string with time zone information (like: "Feb 1 2002 17:05 +7:00"). JScript and VC#.NET have no problem parsing date/time strings with time zone info, but I can't seem to parse date/time string in VC++. :( Platform: WinXP Pro, VC++.NET (unmanaged) Thanks in advance Mike

      M Offline
      M Offline
      Matt Newman
      wrote on last edited by
      #2

      From Visual C++ .NET documentation:

      Remarks
      If the string was successfully converted to a date/time value, the value of this COleDateTime object is set to that value and its status to valid.

      Note Year values must lie between 100 and 9999, inclusively.
      The lpszDate parameter can take a variety of formats. For example, the following strings contain acceptable date/time formats:

      "25 January 1996"
      "8:30:00"
      "20:30:00"
      "January 25, 1996 8:30:00"
      "8:30:00 Jan. 25, 1996"
      "1/25/1996 8:30:00" // always specify the full year,
      // even in a 'short date' format

      Seems odd but you can't get it from ParseDateTime -:suss:Matt Newman:suss: -Sonork ID: 100.11179:BestSnowman
      †

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups