@atlaskit/datetime-picker
Version:
A date time picker allows the user to select an associated date and time.
9 lines • 311 B
JavaScript
/**
* Formats a date, time, and zone into a ISO string.
*/
export function formatDateTimeZoneIntoIso(date, time, zone) {
// 12:00 => 12:00, 1:00 => 01:00
const needsLeadingZero = /^\d:/;
const sanitizedTime = needsLeadingZero.test(time) ? `0${time}` : time;
return `${date}T${sanitizedTime}${zone}`;
}