sketchucation logo sketchucation
    • Login
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Shadow Time Mismatch?

    Scheduled Pinned Locked Moved Developers' Forum
    12 Posts 2 Posters 360 Views 2 Watching
    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.
    • thomthomT Offline
      thomthom
      last edited by

      Why doesn't the times match?

      ShadowTime.png

      Thomas Thomassen — SketchUp Monkey & Coding addict
      List of my plugins and link to the CookieWare fund

      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        Even when I change the timezone in SU ruby return the same number.

        UTC0.png

        Thomas Thomassen — SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund

        1 Reply Last reply Reply Quote 0
        • TIGT Offline
          TIG Moderator
          last edited by

          I concur.

          ["TZOffset"] should return the offset from the TZ ???
          But it seems flaky - my default SKP template [geo-located in the UK] says '1.0' when I first list the shadow_info as an array, but if I try to extract it as above it returns '-0.0' ?
          The "ShadowTime" is always returned as 1 hour ahead of the displayed time 😕
          The setting for 'daylight-saving' seems equally useless... 😒

          TIG

          1 Reply Last reply Reply Quote 0
          • thomthomT Offline
            thomthom
            last edited by

            Oddly enough I get the time I want if I do this: model.shadow_info['ShadowTime'].getutc

            Which is just odd... Probably just a coincidence with my computers TZ.

            😕

            Thomas Thomassen — SketchUp Monkey & Coding addict
            List of my plugins and link to the CookieWare fund

            1 Reply Last reply Reply Quote 0
            • TIGT Offline
              TIG Moderator
              last edited by

              I think you have it.
              It's reporting the time at GMT - you need to convert it to your [or your SKP's] local time...
              EDIT .gmt? returns false !

              TIG

              1 Reply Last reply Reply Quote 0
              • thomthomT Offline
                thomthom
                last edited by

                @tig said:

                you need to convert it to your [or your SKP's] local time...

                How do you get that?

                Thomas Thomassen — SketchUp Monkey & Coding addict
                List of my plugins and link to the CookieWare fund

                1 Reply Last reply Reply Quote 0
                • thomthomT Offline
                  thomthom
                  last edited by

                  hmm...

                  Is SU returning the time in UTC?
                  And Ruby thinks it's local time - so it add's the computers TZ to the string?

                  Thomas Thomassen — SketchUp Monkey & Coding addict
                  List of my plugins and link to the CookieWare fund

                  1 Reply Last reply Reply Quote 0
                  • thomthomT Offline
                    thomthom
                    last edited by

                    No... this is all wrong... my brain melts to a mush of this...

                    Thomas Thomassen — SketchUp Monkey & Coding addict
                    List of my plugins and link to the CookieWare fund

                    1 Reply Last reply Reply Quote 0
                    • TIGT Offline
                      TIG Moderator
                      last edited by

                      Time.zone returns the time-zone that SketchUp thinks the SKP is in.
                      I think this 1 hour stuff is because the Daylight saving is etc false but the time.zone says it is in effect !

                      TIG

                      1 Reply Last reply Reply Quote 0
                      • TIGT Offline
                        TIG Moderator
                        last edited by

                        Perhaps Time.localtime
                        to your local settings ?
                        .gm and .utc do similar conversions, the latter converting to UTC [GMT?]

                        TIG

                        1 Reply Last reply Reply Quote 0
                        • thomthomT Offline
                          thomthom
                          last edited by

                          This will create a Time object with correct timezome offset from UTC:

                          <span class="syntaxdefault"><br />model </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_model<br />modeltime </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">shadow_info</span><span class="syntaxkeyword">[</span><span class="syntaxstring">'ShadowTime'</span><span class="syntaxkeyword">].</span><span class="syntaxdefault">getutc<br />tz_offset </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">shadow_info</span><span class="syntaxkeyword">[</span><span class="syntaxstring">'TZOffset'</span><span class="syntaxkeyword">]</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">*</span><span class="syntaxdefault"> 60 </span><span class="syntaxkeyword">*</span><span class="syntaxdefault"> 60&nbsp;</span><span class="syntaxkeyword">/&nbsp;-</span><span class="syntaxdefault">1<br />utc_time </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> Time</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">at</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> modeltime</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">to_i </span><span class="syntaxkeyword">+</span><span class="syntaxdefault"> tz_offset </span><span class="syntaxkeyword">)<br />&nbsp;</span><span class="syntaxdefault"></span>
                          

                          However, need to work out a reliable way to detect the mis-match in case it gets fixed in future SketchUp versions.

                          Thomas Thomassen — SketchUp Monkey & Coding addict
                          List of my plugins and link to the CookieWare fund

                          1 Reply Last reply Reply Quote 0
                          • thomthomT Offline
                            thomthom
                            last edited by

                            <span class="syntaxdefault"><br />model </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_model<br /><br />modeltime </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">shadow_info</span><span class="syntaxkeyword">[</span><span class="syntaxstring">'ShadowTime'</span><span class="syntaxkeyword">]<br /></span><span class="syntaxdefault">unless modeltime</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">utc</span><span class="syntaxkeyword">?<br /></span><span class="syntaxdefault">  time </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">shadow_info</span><span class="syntaxkeyword">[</span><span class="syntaxstring">'ShadowTime'</span><span class="syntaxkeyword">].</span><span class="syntaxdefault">getutc<br />  tz_offset </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">shadow_info</span><span class="syntaxkeyword">[</span><span class="syntaxstring">'TZOffset'</span><span class="syntaxkeyword">]</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">*</span><span class="syntaxdefault"> 60 </span><span class="syntaxkeyword">*</span><span class="syntaxdefault"> 60&nbsp;</span><span class="syntaxkeyword">/&nbsp;-</span><span class="syntaxdefault">1<br />  modeltime </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> Time</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">at</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> time</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">to_i </span><span class="syntaxkeyword">+</span><span class="syntaxdefault"> tz_offset </span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">end<br /></span>
                            

                            ❓

                            Thomas Thomassen — SketchUp Monkey & Coding addict
                            List of my plugins and link to the CookieWare fund

                            1 Reply Last reply Reply Quote 0
                            • 1 / 1
                            • First post
                              Last post
                            Buy SketchPlus
                            Buy SUbD
                            Buy WrapR
                            Buy eBook
                            Buy Modelur
                            Buy Vertex Tools
                            Buy SketchCuisine
                            Buy FormFonts

                            Advertisement