ical.js icon indicating copy to clipboard operation
ical.js copied to clipboard

ICAL.Time.fromUnixTime

Open radarfox opened this issue 5 years ago • 0 comments

Why is this function missing? The other from* methods have their static factory method in place, like ICAL.Time.fromData, fromDateString, ... But fromUnixTime is defined only at ICAL.Time instance.

I have found nothing about this in the documentation nor the issues.

My current implementation is the following, but I don't think it has a good performance with that repeated Time object initializations. What is the correct way to do this? I also need to make the time zone floating.

function fromUnixTime (unixTime) {
  const icalTime = new ICAL.Time();
  icalTime.fromUnixTime(unixTime);
  return new ICAL.Time({...icalTime.toJSON(), timezone: null});
}

radarfox avatar Apr 15 '20 19:04 radarfox