Skip to content

Commit

Permalink
fix: select routing time based on current time #402
Browse files Browse the repository at this point in the history
  • Loading branch information
rizwan committed Oct 16, 2023
1 parent fe89162 commit 8d1056a
Showing 1 changed file with 26 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,10 @@ export default {
},
places: []
},
components: {

},
components: {},
data: () => {
return {
// hours: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23],
timesOfTheDay: [
// {
// label: 'now',
// value: 'now'
// },
{
label: 'morning',
value: 'heat_morning'
Expand All @@ -41,27 +34,19 @@ export default {
}
},
computed: {
timesOfTheDayLabel () {
return this.timesOfTheDay.map( t => {
timesOfTheDayLabel() {
return this.timesOfTheDay.map(t => {
return {
label: `${this.$t('timeBasedRoute.'+ t.label)}`,
label: `${this.$t('timeBasedRoute.' + t.label)}`,
value: t.value
}
})
},
},
methods: {
routeOnHotDays(time) {
/*routeOnHotDays(time) {
console.log('>>> timeBasedRoute >>> routeOnHotDays ', time)
},
/* addHour() {
if(this.selectedHour >= 0 && this.selectedHour < 23)
this.selectedHour++
},
subtracthour() {
if(this.selectedHour > 0 && this.selectedHour <= 23)
this.selectedHour--
}, */
},*/
departHourChange() {
let appRouteData = this.$store.getters.appRouteData
// console.log('>>> departHourChange ', this.selectedHour, appRouteData)
Expand All @@ -70,6 +55,26 @@ export default {
// this.$store.commit('appRouteData', appRouteData)
EventBus.$emit('appRouteDataChanged', appRouteData)
},
getTimeOfDay(hour, minute) {
// Function to determine the time of the day
const totalMinutes = hour * 60 + minute

if (totalMinutes >= 0 && totalMinutes <= 11 * 60 + 30) {
return this.timesOfTheDay[0].value // Morning
} else if (totalMinutes <= 14 * 60 + 30) {
return this.timesOfTheDay[1].value // Noon
} else if (totalMinutes <= 17 * 60 + 30) {
return this.timesOfTheDay[2].value // Afternoon
} else {
return this.timesOfTheDay[3].value // Evening
}
}
},
created() {
const currentTime = new Date()
const currentHour = currentTime.getHours()
const currentMinute = currentTime.getMinutes()

this.selectedHour = this.getTimeOfDay(currentHour, currentMinute)
}
}

0 comments on commit 8d1056a

Please sign in to comment.