Sha256: 3266d98ae2b753978683a2881890cfb0129ccfd9843c3e46e95c70c90a9a2854
Contents?: true
Size: 860 Bytes
Versions: 29
Compression:
Stored size: 860 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() { 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') } toWeekday() { return this.value.strftime('%a') } toIso() { return this.value.toISOString() } }
Version data entries
29 entries across 29 versions & 1 rubygems