Flic Home

    Community

    • Login
    • Search
    • Popular
    • Users

    Can FlicScript Add Support for Local Timezones (with DST)

    Flic Hub SDK
    2
    4
    88
    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.
    • pico
      pico last edited by

      One of my scripts changes brightness based on the current time. I've noticed that FlicScript always uses UTC time, and there is no way to set a timezone in the app or even in code. When using new Date().toLocaleString('en-US', {timeZone: 'America/Los_Angeles'}) the UTC date is still returned.

      It isn't too hard to just get the UTC time and change the hours offset manually (which I'm currently doing), but it becomes a hassle when changes with Daylight Savings Time is factored in.

      Would is be possible to add a way to set the timezone in the app or something so that new Date() returns the date in the specified timezone (or the current location and timezone could be detected automatically), or at least make toLocaleString work properly so timezones can be adjusted manually an have DST accounted for automatically.

      Thank you!

      Emil 1 Reply Last reply Reply Quote 0
      • Emil
        Emil FlicTeam @pico last edited by

        @pico We currently use QuickJS and it seems like that js engine does not support that Intl feature.

        We might add the feature to set time zone, it can be useful for a few other purposes as well, e.g. in timestamp header for our Internet Request action. But right now I suggest to use the workaround I suggested.

        1 Reply Last reply Reply Quote 0
        • pico
          pico @Emil last edited by

          @Emil Thanks for getting back to me. So no chance on adding Intl.DateTimeFormat API support to FlicScript or including a way to set the timezone in the app that is passed down into FlicScript?

          Emil 1 Reply Last reply Reply Quote 0
          • Emil
            Emil FlicTeam @pico last edited by

            @pico As you can see on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString, the parameters supplied are only used if the Intl.DateTimeFormat API is supported. We don't support that API and hence you can't get any time zone support, unfortunately.

            I would suggest you to manually extract the components using getUTCHours, getUTCMinutes, getUTCSeconds etc. and then apply your time zone offset and DST formula manually, which should be doable if you know you will only be using a fixed time zone.

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