Hi!
I see what you mean. You wanted to use * as an operator, because it’s written on Roblox Dev Hub. * in this case is not meant to be used as an string patter class modifier, but only marks further explanation, which is:
*This value can vary depending on the current locale.
Notice the * character? The return value of %Z might be an acronym or not, depending on the zone.
What to do now?
You’ll have to abbreviate manually. There are different ways to do this and I tested a couple, but found the following as reasonably short and one of the most performant according to some short tests I did.
local timeZone = os.date("%Z"); -- Default time stamp is os.time()
timeZone = timeZone:gsub("%l+%s*", "");
print(timeZone);
-- %l --> lower case class
-- %s --> space or white space character class
-- + --> matches 1 or more of the preceeding character class
-- * --> matches 0 or more of the proceeding character class
See how string.gsub() works by following this link: string | Roblox Creator Documentation.
First, we remove all lower case characters and all white spaces.
The following text is of a more informative nature (if you are interested in micro-optimization).
The worst alternative is gradual string concatenation. Splitting string into a table, looping through that table and searching for upper cases while gradually concatenating strings performed significantly worse. Execution time was an order of magnitude lower, while memory usage was the worst too, because of the way lua combines strings (gradual concatenation hashes new strings in memory).
Looping through all characters, inserting them in a new table, and concatenating that table performed pretty well too, but the code was longer.
More about string patterns:
Different display?
If you wanted to have abbreviations written differently, for example GTM instead of UTC, or have GMT +1 written instead of CEST, it would open up some further ways to find the time zone.