Skip to content

Commit

Permalink
Merge pull request #5748 from nextcloud/enh/5745/add-booking-date
Browse files Browse the repository at this point in the history
fix(appointments): add date to booking detail view
  • Loading branch information
miaulalala authored Feb 8, 2024
2 parents c7f5aa9 + eeacfa6 commit cf2843b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/components/Appointments/AppointmentDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
{{ config.name }}
</h2>
<div class="booking__time">
{{ startTime }} - {{ endTime }}
{{date}} {{ startTime }} - {{ endTime }}
</div>
<!-- Description needs to stay inline due to its whitespace -->
<span class="booking__description">{{ config.description }}</span>
Expand Down Expand Up @@ -81,7 +81,7 @@ import {
} from '@nextcloud/vue'
import autosize from '../../directives/autosize.js'
import { timeStampToLocaleTime } from '../../utils/localeTime.js'
import { timeStampToLocaleTime, timeStampToLocaleDate } from '../../utils/localeTime.js'
export default {
name: 'AppointmentDetails',
Expand Down Expand Up @@ -144,6 +144,9 @@ export default {
endTime() {
return timeStampToLocaleTime(this.timeSlot.end, this.timeZoneId)
},
date() {
return timeStampToLocaleDate(this.timeSlot.start, this.timeZoneId)
}
},
methods: {
save() {
Expand Down
13 changes: 13 additions & 0 deletions src/utils/localeTime.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,16 @@ export function timeStampToLocaleTime(timeStamp, timeZoneId) {
minute: 'numeric',
})
}

/**
* Format a time stamp as local date
*
* @param timeStamp {Number} unix times stamp in seconds
* @param timeZoneId {string} IANA time zone identifier
* @return {string} the formatted date
*/
export function timeStampToLocaleDate(timeStamp, timeZoneId) {
return (new Date(timeStamp * 1000)).toLocaleDateString(locale, {
timeZone: timeZoneId,
})
}

0 comments on commit cf2843b

Please sign in to comment.