Skip to content

Instantly share code, notes, and snippets.

@srttk
Created May 23, 2017 11:43
Show Gist options
  • Save srttk/947d95338847bc833f94a8becc2c482e to your computer and use it in GitHub Desktop.
Save srttk/947d95338847bc833f94a8becc2c482e to your computer and use it in GitHub Desktop.
get set typescript properties
// Format conversions
get _startDate() {
if (this.startDate) {
let d = new Date(this.startDate);
return d.toLocaleDateString();
}
return '';
}
set _startDate(value) {
if (value) {
let d = new Date(value);
let utcDate = new Date(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate(), 0, 0, 0))
this.startDate = utcDate.toJSON();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment