export default class Parser { public static strDate ( date ) { if ( date . indexOf ( "/" ) === 2 ) { return new Date ( date . split ( "/" ) . reverse ( ) . join ( "-" ) + " 00:00:00" ) ; } const nullDate = /(0{4})-(0{2})-(0{2})(T(0{2}):(0{2}):(0{2}))?/ ; if ( nullDate . test ( date ) ) { return new Date ( 0 ) ; } else { if ( isNaN ( Date . parse ( date ) ) ) { return null ; } return new Date ( date ) ; } } public static strNumber ( n ) { return isNaN ( parseFloat ( n ) ) ? 0 : parseFloat ( n ) ; } public static nBoolean ( n ) { return n === 1 ? true : false ; } public static parseGxState ( gxState ) { let data ; try { data = JSON . parse ( gxState ) ; } catch ( e ) { data = JSON . parse ( gxState . replace ( /\\>/g , "&gt" ) ) ; } return data ; } public static image ( base64Buffer ) { if ( ! base64Buffer ) { return "" ; } return `data:image/jpeg;base64,${ base64Buffer . toString ( "base64" ) }` ; } }