import { TimeConvention } from "." ; export class TimeHelper { param value public static isValidDate ( value ) { return Object . prototype . toString . call ( value ) === '[object Date]' && ! isNaN ( value . getTime ( ) ) ; } param date public static cloneDate ( date ) { return this . isValidDate ( date ) ? new Date ( date . getTime ( ) ) : null ; } /**
     * Suffix number with zero
     */ public static suffixZero ( value , size = 2 ) { while ( value . length < size ) { value = `0${ value }` ; } return value ; } param hours param timeConvention public static hoursValue ( hours , timeConvention ) { if ( timeConvention === TimeConvention . Hours24 ) { return this . suffixZero ( hours . toString ( ) ) ; } else { if ( hours === 0 ) { return `12 AM` ; } else if ( hours < 12 ) { return `${ this . suffixZero ( hours . toString ( ) ) } AM` ; } else { if ( hours === 12 ) { return `12 PM` ; } else { return `${ this . suffixZero ( ( hours % 12 ) . toString ( ) ) } PM` ; } } } } }