summaryrefslogtreecommitdiff
path: root/src/components/Mixins/LocalTimezoneLabelMixin.js
blob: 0f96a45f29594943d5dfbc03bf790243828b836b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import { format } from 'date-fns-tz';

const LocalTimezoneLabelMixin = {
  methods: {
    localOffset() {
      const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
      const shortTz = this.$options.filters.shortTimeZone(new Date());
      const pattern = `'${shortTz}' O`;
      return format(new Date(), pattern, { timezone }).replace('GMT', 'UTC');
    }
  }
};

export default LocalTimezoneLabelMixin;