Skip to content

Commit

Permalink
fix:記述の整理
Browse files Browse the repository at this point in the history
  • Loading branch information
mathsuky committed Dec 13, 2024
1 parent 8727111 commit 3bc33a3
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions src/components/event/EventFormTimeAndPlaceInstant.vue
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,18 @@ export default class EventFormTimeAndPlaceInstant extends Vue {
}
}
private ajustDate(dateStr: string, days: number): string {
let date = new Date(dateStr)
date.setDate(date.getDate() + days)
return date.toISOString().split('T')[0]
}
public autoFillDateEnd() {
if (!this.dateEndMem) {
this.dateDiff = 0
this.dateEndMem = this.dateStartMem
} else {
let startDate = new Date(this.dateStartMem)
let endDate = startDate
endDate.setDate(startDate.getDate() + this.dateDiff)
this.dateEndMem = endDate.toISOString().split('T')[0]
this.dateEndMem = this.ajustDate(this.dateStartMem, this.dateDiff)
}
}
Expand All @@ -144,31 +147,24 @@ export default class EventFormTimeAndPlaceInstant extends Vue {
}
let endTime = new Date(this.timeStartInput)
endTime.setMinutes(endTime.getMinutes() + this.minuteDiff)
const endHour = endTime.getHours()
const endMinute = endTime.getMinutes()
// 正の向きに日付を跨いだかどうかの判定
if (endTime.getDate() - new Date(this.timeStartInput).getDate() > 0) {
let startDate = new Date(this.dateEndMem)
let endDate = startDate
endDate.setDate(startDate.getDate() + 1)
this.dateEndMem = endDate.toISOString().split('T')[0]
this.dateEndMem = this.ajustDate(this.dateEndMem, 1)
}
// 負の向きに日付を跨いだかどうかの判定
else if (endTime.getDate() - new Date(this.timeEndInput).getDate() < 0) {
let startDate = new Date(this.dateEndMem)
let endDate = startDate
endDate.setDate(startDate.getDate() - 1)
this.dateEndMem = endDate.toISOString().split('T')[0]
this.dateEndMem = this.ajustDate(this.dateEndMem, -1)
}
const endHour = endTime.getHours()
const endMinute = endTime.getMinutes()
this.timeEndMem = `${String(endHour).padStart(2, '0')}:${String(
endMinute
).padStart(2, '0')}`
}
public calcDateDiff() {
if (this.dateStartMem && this.dateEndMem) {
const startDate = new Date(this.dateStartMem)
Expand Down

0 comments on commit 3bc33a3

Please sign in to comment.