Change the Timezone

C, 109 bytes

a,b,c;f(char*t,char*z){for(c=0;z[3];t=z+=3)sscanf(t,"%d:%d",&a,&b),c+=b+a*60;printf("%d:%02d",c/60%24,c%60);}

Invoke as follows:

int main() { f("17:25", "UTC+09:00"); }

JavaScript (ES6), 101 bytes

(t,z,g=s=>+(s[3]+s[7]+s[8])+s.slice(3,6)*60,m=g('UTC+'+t)+g(z)+1440)=>(m/60%24|0)+':'+(m/10%6|0)+m%10

Would be 121 bytes if I padded the hours.


Python 2, 129 bytes

def T(t,a):f=[int.__add__,int.__sub__]["-"in a];m=f(int(t[3:5]),int(a[7:9]));print`f(int(t[0:2])+m/60,int(a[4:6]))%24`+":"+`m%60`

Call as T("02:45", "UTC-05:33")

Tags:

Date

Code Golf