Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved time and time zones

    Brainstorm
    6
    18
    1368
    Loading More Posts
    • 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.
    • hskoglund
      hskoglund last edited by

      Maybe you'll have to bite the bullet and go for the mother lode https://www.iana.org/time-zones

      mzimmers 1 Reply Last reply Reply Quote 0
      • mzimmers
        mzimmers @hskoglund last edited by

        @hskoglund unfortunately, even that doesn't have what I'm looking for; at least I didn't see it. Lots of other stuff, but not this.

        hskoglund 1 Reply Last reply Reply Quote 0
        • hskoglund
          hskoglund @mzimmers last edited by

          @mzimmers Lots of stuff it is, but for example, if I look at my Ubuntu 19.10 machine, and go to /usr/share/zoneinfo (which is Ubuntu's copy of that mother lode), if i type for example the CET file, I get lots of junk but in the end I get

          I?I??J?K??L̿?M??N???OnnP???QW??Rle?S7l?TLG?UN?V,)?V?0?XFX??Y?(Z???[?
          \?]??^?_??`_?a}?b??c]̐d?e=????g??g藐h?r?i?y?j?T?k?[?l?qm?=?n?Soh?p?5qQ<rfs1tE?uv/?v??x??x??y?ِz??{λ?|?}???~y????  CETCEST
          CET-1CEST,M3.5.0,M10.5.0/3
          

          so it's there. But the zdump program refuses to dump it, I tried all the command switches :-(

          mzimmers 1 Reply Last reply Reply Quote 0
          • mzimmers
            mzimmers @hskoglund last edited by

            @hskoglund so, if I understand this, I'd have to build the IANA software, generate all the files, and extract the TZ string I want from each one. That's just too labor-intensive to be a viable approach.

            I'm still amazed that someone out there doesn't maintain a table stored in a grid on a web page somewhere that I could just grab, but oh well...

            hskoglund JonB 2 Replies Last reply Reply Quote 0
            • hskoglund
              hskoglund @mzimmers last edited by

              @mzimmers said in time and time zones:

              I'm still amazed that someone out there doesn't maintain a table stored in a grid on a web page somewhere that I could just grab, but oh well...

              Well never say never, if you build those files, you could be the one maintaining that table :=)

              1 Reply Last reply Reply Quote 2
              • JonB
                JonB @mzimmers last edited by

                @mzimmers
                Can you give some "official", "definitive" link to the TZ formats you are talking about? Is there an RFC or an official body or something? So far I think I only saw a link to some example from 2012. Maybe there is a "body" which has a web service to return the tz format you require from a country name?

                mzimmers 1 Reply Last reply Reply Quote 0
                • mzimmers
                  mzimmers @JonB last edited by

                  @JonB I wish I could. If I knew of such a body, it might have helped me in my search for the table I was looking for. I only know of it the POSIX time zone format as it's referenced by IANA and a few other sites like this.

                  JonB 1 Reply Last reply Reply Quote 0
                  • JonB
                    JonB @mzimmers last edited by JonB

                    @mzimmers
                    OK, so this is all to do with zoneinfo. Are you Linux?

                    jon@ubuntu-19:~$ file /usr/share/zoneinfo/America/Los_Angeles 
                    /usr/share/zoneinfo/America/Los_Angeles: timezone data, version 2, 5 gmt time flags, 5 std time flags, no leap seconds, 186 transition times, 5 abbreviation chars
                    

                    Start reading from man tzfile (if you're not Linux man pages are available online).

                    I don't know where you ended up getting your table from, and the strings in the "tz extended format" for each "friendly" country name, but there may be a call or enough information there if you want to get/make these strings. If the host for your Qt app is Linux, you could leverage that from code.

                    Meanwhile, you might be interested in my own solution for the world's horrendous timezone rules? Abolish all timezones, and daylight savings, world-wide. Everywhere works on identical current time. (All set to one standard, which will obviously be UK/London/GMT/UTC.) If it's 08:14am in England, then it's same in Australia. So now there is no time conversions anywhere. The only difference is if I go to work from 8am to 5pm in England, Aussies go to work from 8pm to 5am, or similar. We all agree what a conference at 9am means, because it's 9am everywhere. Computer programs no longer have to worry about where you are. Simplez! I don't know why they don't put me in charge of international issues like this....

                    kshegunov 1 Reply Last reply Reply Quote 0
                    • kshegunov
                      kshegunov Moderators @JonB last edited by

                      @JonB said in time and time zones:

                      I don't know where you ended up getting your table from, and the strings in the "tz extended format" for each "friendly" country name, but there may be a call or enough information there if you want to get/make these strings. If the host for your Qt app is Linux, you could leverage that from code

                      @mzimmers, I'd rather advise this instead of calling things on the command line:
                      http://man7.org/linux/man-pages/man3/strptime.3.html
                      http://man7.org/linux/man-pages/man3/strftime.3.html

                      unfortunately it does seem you need to build the TZ strings by hand. At least that's my understanding ...

                      Read and abide by the Qt Code of Conduct

                      JonB 1 Reply Last reply Reply Quote 0
                      • JonB
                        JonB @kshegunov last edited by JonB

                        @kshegunov
                        I never intended he should do anything as a command (unless there is a convenient one which returns all the strings, which I have not seen). Only use the information from code. I thought the information in man tzfile where it documents the structure/content of the file would be enough to generate the "extended TZ format" string from?

                        strftime/strptime() are for dealing with datetime instances. I don't see how they would help generating the formatting strings he wants.

                        kshegunov 1 Reply Last reply Reply Quote 0
                        • kshegunov
                          kshegunov Moderators @JonB last edited by kshegunov

                          May be, but I'm not convinced. This file may very well be in a privileged location, and it may change at any time under your feet (while you read), and ... well it's a file, you get it ... not ideal, by far.

                          @JonB said in time and time zones:

                          I don't see how they would help generating the formatting strings he wants.

                          You could extract the pertinent identifiers from the dt instances is the point (e.g. offsets and such). But again ... not ideal, by far.

                          Read and abide by the Qt Code of Conduct

                          1 Reply Last reply Reply Quote 0
                          • mzimmers
                            mzimmers last edited by

                            Not ideal, to say the least. I'm going to stand down on this exercise for now. Thanks to all who looked.

                            1 Reply Last reply Reply Quote 0
                            • Kent-Dorfman
                              Kent-Dorfman last edited by Kent-Dorfman

                              what you are asking for is POSIX TZ format. It can be pulled or generated from the POSIX tzfile(5) database. A quick search of the database on my machine shows that all of the timesonze files I searched contained a newline terminated TZ string fallback for dates after the prior exception rules. You most likely would have to parse the tzfiles according to the zone selected and use the fallback string if it exists, or build the correct string from the data if it doesn't exist. This of course assumes that you are on a unix/linux machine.

                              1 Reply Last reply Reply Quote 1
                              • First post
                                Last post