/**
 * Represents a list of hours in a 12 hour clock format, with the index of each
 * hour representing that hour's hour in a 24 hour clock format.
 */ const hours = [ '12 AM' , '1 AM' , '2 AM' , '3 AM' , '4 AM' , '5 AM' , '6 AM' , '7 AM' , '8 AM' , '9 AM' , '10 AM' , '11 AM' , '12 PM' , '1 PM' , '2 PM' , '3 PM' , '4 PM' , '5 PM' , '6 PM' , '7 PM' , '8 PM' , '9 PM' , '10 PM' , '11 PM' , ] ; /**
 * Represents the regex used to correctly match a string in the proper time
 * format that the item spreadsheet uses.
 */ const regex = /^(\d{1,2}\s?(am|pm))\s?(–|-)\s?(\d{1,2}\s?(am|pm))$/i ; /**
 * Represents the hours of a full day in a 24 hour clock format.
 */ const allDay = hours . map ( ( hour ) => hours . indexOf ( hour ) ) ; param string return export function timeArray ( string ) { if ( string . toLowerCase ( ) === 'all day' ) { return allDay ; } const matches = regex . exec ( string . toUpperCase ( ) ) ! ; const timespan = [ ] ; const [ , beginning , , , end ] = matches ; let index = hours . indexOf ( beginning ) ; while ( index !== hours . indexOf ( end ) ) { timespan . push ( index ) ; index = index === 23 ? 0 : index + 1 ; } return timespan ; }