Given a time and a timezone as input, output the time in that timezone.
The time will be given in 24 hour format like so:
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:
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
The timezone will be given in the following format:
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
UTC-02:50, you would subtract 2 hours and 50 minutes from 24:56:
24:56 02:50 - ----- 22:06
The output would be
Input: 08:50 and UTC-06:00 Output: 02:50
Input: 09:42 and UTC+05:45 Output: 15:27
Input: 06:42 and UTC+13:00 Output: 19:42
Input: 02:40 and UTC-10:00 Output: 16:40
Note that this has gone to the previous day.
Input: 17:25 and UTC+09:00 Output: 02:25
Note that this has gone to the following day.
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
In the case of half past midnight, the correct representation should be
The shortest code in bytes wins.
08:74would not appear? Same for the UTC offsets? \$\endgroup\$
1:5be valid instead of
1:05? I'd think only the hours shouldn't be padded. Also your example with
24:56should that not be
00:56since you've stated a range up to
24:00and express similar in your half past midnight scenario? \$\endgroup\$