time-convertor

Convert time across timezones
git clone http://git.hanabi.in/repos/time-convertor.git
Log | Files | Refs | README | LICENSE

prepData.js (570B)


      1 import moment from 'moment-timezone';
      2 
      3 function prepData(time, TZ2, TZ1 = '') {
      4   const ISOtime = time.toISOString();
      5   const tz = TZ1 || moment.tz.guess();
      6   const firstTZ = tz.replace(/_/g, ' ');
      7   const now = moment(ISOtime);
      8   const firstAbbr = moment.tz.zone(tz).abbr(now);
      9   const secondAbbr = moment.tz.zone(TZ2).abbr(now);
     10   let fmtTime1 = now.tz(tz).format('HH:mm:ss MMM DD, YYYY');
     11   let fmtTime2 = now.tz(TZ2).format('HH:mm:ss MMM DD, YYYY');
     12   return {
     13     firstAbbr,
     14     firstTZ,
     15     fmtTime1,
     16     fmtTime2,
     17     secondAbbr,
     18   };
     19 }
     20 
     21 export default prepData;