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. Other Discussions
  3. IT & Infrastructure
  4. Time zones [modified]

Time zones [modified]

Scheduled Pinned Locked Moved IT & Infrastructure
help
3 Posts 2 Posters 0 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.
  • N Offline
    N Offline
    Nyarlatotep
    wrote on last edited by
    #1

    I've a weird problem making me crazy !!! I've to read a sequence of dates from a text file and convert these dates into time_t. I DON't want to take into account timezones and daylight savings, so the input date must be converted into the exact output date. So, i've avoided mktime() to convert from tm (filled up with string dates from source) to time_t. The nex solution i've used was to convert a SYSTEMTIME to a time_t with these functions (based on a similar function, UnixTimeToSystemTime(), in MSDN): void FileTimeToUnixTime(LPFILETIME pft, time_t *t) { LONGLONG ll; ll = pft->dwHighDateTime; ll <<= 32; ll |= pft->dwLowDateTime; ll = ll - 116444736000000000; *t = ll / 10000000; } void SystemTimeToUnixTime(LPSYSTEMTIME pst, time_t *t) { FILETIME ft; SystemTimeToFileTime(pst, &ft); FileTimeToUnixTime(&ft, t); } because I was sure that SystemTimeToFileTime() only converts to SYSTEMTIME format to FILETIME format without any other considerations like timezone or daylight saving. In my PC these work well. When I've run the code in another PC, the resulting date is 1 hour back. (it's very strange too, because that PC has the same date settings of mine). I can't achive the result to obatin a time_t that reflect the same source date, without variations caused by currenctly timezone and daylight saving settings. -- modified at 7:13 Thursday 3rd August, 2006

    J 1 Reply Last reply
    0
    • N Nyarlatotep

      I've a weird problem making me crazy !!! I've to read a sequence of dates from a text file and convert these dates into time_t. I DON't want to take into account timezones and daylight savings, so the input date must be converted into the exact output date. So, i've avoided mktime() to convert from tm (filled up with string dates from source) to time_t. The nex solution i've used was to convert a SYSTEMTIME to a time_t with these functions (based on a similar function, UnixTimeToSystemTime(), in MSDN): void FileTimeToUnixTime(LPFILETIME pft, time_t *t) { LONGLONG ll; ll = pft->dwHighDateTime; ll <<= 32; ll |= pft->dwLowDateTime; ll = ll - 116444736000000000; *t = ll / 10000000; } void SystemTimeToUnixTime(LPSYSTEMTIME pst, time_t *t) { FILETIME ft; SystemTimeToFileTime(pst, &ft); FileTimeToUnixTime(&ft, t); } because I was sure that SystemTimeToFileTime() only converts to SYSTEMTIME format to FILETIME format without any other considerations like timezone or daylight saving. In my PC these work well. When I've run the code in another PC, the resulting date is 1 hour back. (it's very strange too, because that PC has the same date settings of mine). I can't achive the result to obatin a time_t that reflect the same source date, without variations caused by currenctly timezone and daylight saving settings. -- modified at 7:13 Thursday 3rd August, 2006

      J Offline
      J Offline
      J4amieC
      wrote on last edited by
      #2

      There is nothing General about this discussion. This is a specific programming question that should go in the specific forum for the language you are using.

      --- How to get answers to your questions[^]

      N 1 Reply Last reply
      0
      • J J4amieC

        There is nothing General about this discussion. This is a specific programming question that should go in the specific forum for the language you are using.

        --- How to get answers to your questions[^]

        N Offline
        N Offline
        Nyarlatotep
        wrote on last edited by
        #3

        Forgive me :) I'll post in the c++ thread ...

        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