Understanding TimeZoneOffset The TimeZoneOffset function returns the difference between the local time and UTC in minutes. This value can be positive or negative depending on your time zone relative to UTC. Handling Negative Offsets If the TimeZoneOffset is negative, it means your local time is ahead of UTC. For example, if the offset is -60 minutes, your local time is 1 hour ahead of UTC. Subtracting the Offset When you subtract a negative offset, you're effectively adding that time to the current time. Here's how it works: Example: If TimeZoneOffset(Now()) returns -60 minutes: DateAdd(Now(), -(-60), TimeUnit.Minutes) becomes DateAdd(Now(), 60, TimeUnit.Minutes). This adds 60 minutes to the current local time, which is correct because your local time is ahead of UTC. Correct Behavior The code correctly adjusts the local time to UTC by accounting for both positive and negative offsets. So, subtracting a negative offset does indeed add the time difference, aligning the local time with UTC. Does this make sense? 😊

I recently asked MS Copilot to explain this MS Power Fx code (which I found online) to me:

UpdateContext ({TimerLocalStartTime: DateAdd(
        Now(),
        -TimeZoneOffset(Now()),
        TimeUnit.Minutes
    )
});

Although I thought I knew exactly what it was doing AND what it intended, I still wanted to check.

The code sets TimerLocalStartTime to the current UTC time

So, Copilot understood the intent of the code but it didn’t pick-up the problems I saw (not least the horribly named variable). So I asked:

If the timezone offset is negative, won’t subtracting the timezone offset actually add the time zone offset, causing unintended results?

Quoted below is the response, which I’ll break down:

Understanding TimeZoneOffset

TheĀ TimeZoneOffsetĀ function returns the difference between the local time and UTC in minutes. This value can be positive or negative depending on your time zone relative to UTC.

Handling Negative Offsets

If theĀ TimeZoneOffsetĀ is negative, it means your local time is ahead of UTC. For example, if the offset is -60 minutes, your local time is 1 hour ahead of UTC.

So far, so good. That’s all correct, which is what you’d expect from the vendor, right?

Subtracting the Offset

When you subtract a negative offset, you’re effectively adding that time to the current time. Here’s how it works:

  • Example: IfĀ TimeZoneOffset(Now())Ā returns -60 minutes:
    • DateAdd(Now(), -(-60), TimeUnit.Minutes)Ā becomesĀ DateAdd(Now(), 60, TimeUnit.Minutes).
    • This adds 60 minutes to the current local time, which is correct because your local time is ahead of UTC.

So, I am (currently) on BST, which is UTC+1. So, 15:00 local time for me is 14:00 UTC. Adding 60 minutes to 15:00 makes it 16:00, which is UTC+2. So, this is completely wrong. It would be correct if it said:

  • This adds 60 minutes to the current UTC time, which is correct because your local time is ahead of UTC.

But that’s not what we want. We want to calculate UTC from the local time. Copilot continues:

Correct Behavior

The code correctly adjusts the local time to UTC by accounting for both positive and negative offsets. So, subtracting a negative offset does indeed add the time difference, aligning the local time with UTC.

Does this make sense? 😊

No, it doesn’t make sense.

I don’t know about you but this feels like exactly the sort of error we can expect from “vibe coders” for years to come. Working out timezone offsets is already a bit of a brain twister, confidently incorrect assertions from your “AI” assistant won’t help!

When your Vice President proudly carries the coffin of a self-avowed white supremacist, Christian nationalist, it’s time to stop lying to yourself.

‘Yes, I did describe the paedophile financier as “my best pal” but there is context…’ The public don’t care about context any more, Peter, so just state your intention to resign in due course.

It’s weird to me that if you have a cat in the kitchen on social media people like it but if you have a cat in your kitchen at a restaurant they call a health inspector

When I send a card or a letter, I don’t consider it to be “on the way” the instant I have addressed and put postage on it. Do you?

I’ve quickly gone from tolerating the inclusion of “AI” in a product to wanting to actively avoid it. The privacy implications alone are a nightmare.

Turns out, I can put a number on the cost of Elon Musk’s “involvement” in UK “politics” during August 2024 and since… 4.3%. Yup. We’ve lost just 4.3% of Followers from the X account our not-for-profit uses since September 2024. It was going steadily down each month but now appears to have levelled off.

To put it another way, 95% of users don’t care what Musk does. So, now you know where you stand, I guess.