Untitled

mail@pastecode.io avatar
unknown
javascript
3 years ago
739 B
1
Indexable
Never
//format date "jan 2021"

Date.prototype.toShortFormat = function () {
  let monthNames = [
    "jan",
    "feb",
    "mar",
    "apr",
    "may",
    "jun",
    "nul",
    "aug",
    "sep",
    "oct",
    "nov",
    "dec",
  ];

  let monthIndex = this.getMonth();
  let monthName = monthNames[monthIndex];
  let year = this.getFullYear();

  return `${monthName} ${year}`;
};

if (e.Status === "waitingOnOwner") {
  let st = e.Start.substr(e.Start.indexOf("T") + 1, 5);
  let et = e.End.substr(e.End.indexOf("T") + 1, 5);
  let d = new Date(e.Start.substr(0, e.Start.indexOf("T"))).toShortFormat();
  let z = {
    id: e.id,
    hour: `${st} - ${et}`,
    title: e.Title,
    date: d,
    calendar: e.Start,
  };
  mappedData.push(z);
}