JSFiddle - React, Tailwind, and code Playground

by vacammar

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js"></script>

JavaScript

(function() {
	'use-strict'
  
    var McmDateEnum = {
      FORMAT_UI: 'DD/MM/YYYY HH:mm:ss',
      FORMAT_CDC_MODE: 'DD-MM-YYYY HH:mm:ss',
      FORMAT_SAMPLE: 'YYYY-MM-DD HH:mm:ss',
      FORMAT_HHMM: 'HH:mm',
      FORMAT_HHMMSS: 'HH:mm:ss',
      FORMAT_DATEPICKER: 'MM/DD/YYYY',
      DDMMYYYY_SLA: 'DD/MM/YYYY',
      DDMMYYYY_MIN: 'DD/MM/YYYY',
      YYYYMMDDTHHMMSS_MIN: 'YYYY-MM-DDTHH:mm:ss'
    };

    var McmDateSeparator = {
      SLASH: '/',
      MINUS: '-'
    };

    function ExaDate(separator) {
      this.separator = separator;
      this.date = undefined;
      this.time = undefined;
      this.datetime = undefined;
			this.timezone = undefined;
    }

		function ExaFormat(separator) {
    	this.separator = separator || McmDateSeparator.SLASH;
      this.date = [];
      this.time = [];
      this.format = undefined;
    }
    
    ExaFormat.prototype.withDay = function() {
    	this.date.push('DD');
      return this;
    }
    
    ExaFormat.prototype.withMonth = function() {
    	this.date.push('MM');
      return this;
    }
    
    ExaFormat.prototype.withYear = function() {
    	this.date.push('YYYY');
      return this;
    }
    
    ExaFormat.prototype.withHours = function() {
    	this.time.push('HH');
      return this;
    }
    
    ExaFormat.prototype.withMinutes = function() {
    	this.time.push('mm');
      return this;
    }    

    ExaFormat.prototype.withSeconds = function() {
    	this.time.push('ss');
      return this;
    }
    
    ExaFormat.prototype.build = function() {
    	var _format = '';      
      var _length = this.date.length;
      var _i = 0;
      if(_length > 0) {      	      	
        for(; _i < _length; _i++) {
        	 _format = _format.concat(this.date[_i]);
           if(_i < _length - 1) {
           	_format = _format.concat(this.separator);
           }
        }
      }
      
      _length = this.time.length;
      if(_length > 0) {
      	_format = _format.concat(' ')        
        _i = 0;
 ...