Skip to content

Instantly share code, notes, and snippets.

@sdevore
Last active July 8, 2021 17:48
Show Gist options
  • Save sdevore/7a86596bc1b7e9031401af1b210b393a to your computer and use it in GitHub Desktop.
Save sdevore/7a86596bc1b7e9031401af1b210b393a to your computer and use it in GitHub Desktop.
how is available defined
get available () {
const status = this.status.toLowerCase()
// if the date is essentially empty then
if (['', '0000-00-00'].includes(this.when_available.trim())) {
// if the status contains `not ready` then show `Coming Soon`
if (status.indexOf('not ready') !== -1) {
return 'Coming Soon'
}
// other wise it is `Available`
return 'Available'
}
// in case the string in `when_available` is not parsable (should not happen) use a `try`
try {
const theDate = new Date(this.when_available)
// 21/07/08 (SCD) #10xnwry [#vf846b, #r54mev] if the status contains `not ready` then always show
// `Coming Soon` (requested change when apartments work started in other tickets)
if (status.indexOf('not ready') !== -1) {
return 'Coming Soon'
}
// if the date is <= now() then 'Available'
if (this.isDateBeforeToday(theDate) || this.isDateToday(theDate)) {
return 'Available'
}
// other wise output the date formatted like Jun 7, 2021
return dateString(theDate, 'MMM d, y')
} catch (e) {
// the date was not parsable so output unknown this should not happen and would indicate
// a problem in the feed
return 'Unknown'
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment