Created
July 7, 2021 15:19
-
-
Save luQman704/5a35972afd106fb98df0301f7ca6f53e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<daterange-component | |
placeholder="Date Range" | |
:format="format" | |
i18n="EN" | |
:captions="{title: 'Choose Date Range For Filters', | |
ok_button: 'Apply'}" | |
@selected="selected" | |
class="input" | |
@events="events" | |
></daterange-component> | |
</template> | |
<script> | |
import moment from "moment-timezone"; | |
export default { | |
name: "DateRangeComponent", | |
props: { | |
format: { | |
default: "DD MMM YYYY" | |
}, | |
outputFormat: { | |
default: "MM/DD/YYYY" | |
}, | |
outputTimezone: { | |
default: "UTC" | |
} | |
}, | |
methods: { | |
events(e) { | |
this.$emit("events", e); | |
}, | |
selected(e) { | |
let startDate = moment(e.start) | |
.tz(this.outputTimezone) | |
.format(this.outputFormat); | |
let endDate = moment(e.end) | |
.tz(this.outputTimezone) | |
.format(this.outputFormat); | |
this.$emit("selected", { | |
start: startDate, | |
end: endDate | |
}); | |
} | |
} | |
}; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment