Skip to content

Instantly share code, notes, and snippets.

@motiko
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save motiko/27ddf03c26c569ccaa86 to your computer and use it in GitHub Desktop.
Save motiko/27ddf03c26c569ccaa86 to your computer and use it in GitHub Desktop.
// http://www.laceysnr.com/2011/02/time-zones-hurt-my-brain-one-way-to-get.html
// by Matt Lacey
string strOffset = System.now().format('Z');
string strOffsetHours = strOffset.substring(0,3);
if(strOffsetHours.startsWith('+'))
{
strOffsetHours = strOffsetHours.substring(1);
}
integer iMinutes = 100 * integer.valueOf(strOffset.substring(3));
double dOffset = double.valueOf(strOffsetHours + '.' + ((iMinutes) / 60));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment