rconjoe/provana-mono

time formatter

Closed this issue · 4 comments

universal date time formatter time zone coming from unix seconds in backend

This is really going to suck. But it's going to save times from getting jacked up all over the UI.

What do we have now

yeah it formats time. but it takes a whole dumbass slot model to do it, then returns the same slot model, with the times converted.

I get how this is useful because you can just pass every snapshot that comes back from a bind through the mixin but it locks you into only using on snapshot binds that return a valid slot model.

What should we change it to

Just some thing that you can pass a unix time to and it spits back out your localized string.

well we need to first find everywhere this formatter is used in components because we're about to break the shit out of it

idk why i keep closing this on accident

okay so there is a formatter now! it takes a unix time and turns it into our localized format compatible with v-cal.

export const formatter = (unix) => {
  const tz = store.state.auth.tz
  const djs = dayjs.unix(unix).format()
  const local = dayjs(djs).tz(tz)
  const formatted = dayjs(local).format('YYYY-MM-DD HH:mm')
  return formatted
}

now I just need to go through and make sure everywhere it's used is switched to the new way of using it. @dustingits halp

Before

const session = formatter(session)

Now

const session = {
  name: name,
  color: color,
  serviceColor: serviceColor,
  start: formatter(data.start),
  end: formatter(data.end)
  status: status, 
  participants: participants,
  ...
}