Sha256: d67191091ea2fe70ca6bce1f314f47e87df5b5d225c6244a0201ceb6ef72a457
Contents?: true
Size: 824 Bytes
Versions: 9
Compression:
Stored size: 824 Bytes
Contents
/* @flow */ /*eslint-disable flowtype/space-before-type-colon */ import moment from 'moment' require('moment-strftime') require('moment-timezone') type DateTimeType = { value: String | Date, zone?: String, } export default class DateTime { constructor({ value, zone='America/New_York' }: DateTimeType) { this.value = this.convertToTimestampZone(value, zone) } convertToTimestampZone(value, zone) { return moment(value).tz(zone) } convertToTimezone(zone='America/New_York') { return this.value.strftime('%a') } toYear() { return this.value.strftime("%Y") } toMonth() { return this.value.strftime("%b") } toMonthFull() { return this.value.strftime("%B") } toDay() { return this.value.strftime("%e") } toIso() { return this.value.toISOString(); } }
Version data entries
9 entries across 9 versions & 1 rubygems