
I've been looking further into the question of UTC. Firstly, I'd got unnecessarily fixated with the local time where the function is called, and, thinking about that a bit more I realised that it's not necessary to pass the current time zone where the code is being executed into the function. It's implicit in the value returned by the Now() function, so the function to return the UTC for any given date/time in any given time zone can be simplified to:
Public Function Local2UTC(dtmLocal As Date, TimeZone As Single) As Date
Dim dtmDifference As Date
' get difference between local date/time and UTC
dtmDifference = Now() - GetUTC()
' convert local date/time to UTC by subtracting difference from local date/time
' and adjusting for time zone in which local date/time value is located
Local2UTC = dtmLocal - dtmDifference - TimeZone / 24
End Function
However, this assumes that adjustments for daylight saving time are the same internationally, which isn't the case. Some countries don't implement daylight saving time or equivalent at all. Others do not start and end daylight saving time on the same dates internationally. The USA and UK end it a couple of weeks apart each year for instance. Consequently, the above function will not always provide the correct result if the time zone is defined solely by the difference between local standard time and UTC. It would be possible to amend the function by adding an argument, to indicate whether daylight saving time is currently in use in the target time zone or not. I don't think it would be necessary to do the same for the time zone in which the code is being executed, as the Now() function's return value takes daylight saving time into account.