Df(z) in global variable adopts layer's time zone

I have a global variable called TZ with $df(z)$ as the formula.
I have a layer with a text field with $df(hh:mm a)$ as the formula.
I have the layer set to America/Los_Angeles
I have the visibility of the layer set to $if(gv(TZ)=“PDT”|gv(TZ)=“PST”,Remove,Always)$

The idea is to have the layer only show when I’m not in my home time zone.

Instead of returning my local time zone, the call to gv(TZ) returns the layer’s time zone so the layer is always set to remove. I was working the first time I set it up but not subsequent trips.

This is actually expected behavior. The formula is evaluated as it’s called inside the layer so it will use whichever timezone the layer is on. One workaround that I can think of is to hardcode your reference timezone in your global instead of using a formula.

Is the idea to put “PDT” into the TZ global? Can you think of a way to accommodate daylight savings without having to manually update it?

Do you get “PST/PDT” as an output to $df(z)$ or “GMT-07:00”?

The output is PDT/PST

For some reason, I’m getting the GMT format. In your case, I think the easiest way is to simply use 2 separate globals for TZ for PDT and PST and do something like:

$if(df(z) = gv(TZ1) | df(z) = gv(TZ2), Remove, Always)$

To stick with one variable, you can do a TZ global with “PDTPST” value and use text converter ($tc()$) like so:

$if(df(z) = tc(cut, gv(TZ), 3) | df(z) = tc(cut, gv(TZ), -3), Remove, Always)$

Formula not tested, but you get the idea. :slight_smile:

If I was getting the GMT format, I can see a way to achieve my goal. But with the PDT/PST I’m getting, the layer will either always be PDT/PST (never visible) or the time will always show my local time (not home time).

It doesn’t really make sense to me that a global would evaluate outside the global scope, but if it’s intended behavior then this post should be closed. I can ask around in the discord for help. Thanks for your help.

A “global” formula will be evaluated inside the scope where its called this is how it works ATM, if you want instead to set your REAL tz to a Global you could do this:

  • Create a flow in the root folder
  • Add a formula trigger, select “content changes” and set formula to $df(Z)$
  • In the action set write global and select your global

This will basically set the global to your root time zone, you can then use this in the layer and it won’t change