Challenge
Given a time and a timezone as input, output the time in that timezone.
Time
The time will be given in 24 hour format like so:
hh:mm
Where hh is the two digit hour and mm is the two digit minute. Note that the hour and the minute will always be padded with zeroes like so:
06:09
All the times given are at UTC+00:00.
The hours in your output do not have to be padded wih zeroes but your time it must be in 24 hour format
Timezone
The timezone will be given in the following format:
UTC±hh:mm
Where ± is either going to be a + or a - and hh, is the two digit hour and mm is the two digit minute (again, these will be padded with zeroes).
To find the time in that timezone, you either add (if the symbol is +) or subtract (if the symbol is -) the time after the UTC± from the inputted time.
For example, if the input was 24:56
and UTC-02:50
, you would subtract 2 hours and 50 minutes from 24:56:
24:56
02:50 -
-----
22:06
The output would be 22:06
.
Examples
Chicago
Input: 08:50 and UTC-06:00
Output: 02:50
Kathmandu
Input: 09:42 and UTC+05:45
Output: 15:27
Samoa
Input: 06:42 and UTC+13:00
Output: 19:42
Hawaii
Input: 02:40 and UTC-10:00
Output: 16:40
Note that this has gone to the previous day.
Tokyo
Input: 17:25 and UTC+09:00
Output: 02:25
Note that this has gone to the following day.
Rules
You must not use any built in date functions or libraries.
Assume all input will be valid times and time offsets.
The timezone will be in the range UTC-24:00
to UTC+24:00
inclusive.
In the case of half past midnight, the correct representation should be 00:30
, not 24:30
.
Winning
The shortest code in bytes wins.
26:02
and08:74
would not appear? Same for the UTC offsets? \$\endgroup\$2:25
) \$\endgroup\$1:5
be valid instead of1:05
? I'd think only the hours shouldn't be padded. Also your example with24:56
should that not be00:56
since you've stated a range up to24:00
and express similar in your half past midnight scenario? \$\endgroup\$