-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
The idea to get 24h+ clock is to determine whether journeyStartTime is over the next day or not.
From HFP data we need: oday, journeyStartTime and tst
Use the following pseudo code:
if (oday === tst(date)) {
is_next_day = false // case 1
} else {
if (oday + journeyStartTime vs tst > 12h) {
is_next_day = true // case 2
} else {
is_next_day = false // case 3
}
}
If is_next_day == true, we add 24 hours to journeyStartTime to get 24h+ clock.
Here are some unit tests done with Javascript to validate that this works. Feel free to translate into Python:
describe('getIsHfpRowNextDay', () => {
it('should return false (case 1 in pseudocode)', () => {
expect(
getIsHfpRowNextDay({
journeyStartTime: '23:55',
oday: '2021-01-01',
tst: '2021-01-01T23:58:00.000Z',
})
).toEqual(false)
})
it('should return false (case 1 in pseudocode)', () => {
expect(
getIsHfpRowNextDay({
journeyStartTime: '00:10',
oday: '2021-01-01',
tst: '2021-01-01T00:11:00.000Z',
})
).toEqual(false)
})
it('should return true (case 2 in pseudocode)', () => {
expect(
getIsHfpRowNextDay({
journeyStartTime: '05:00',
oday: '2021-01-01',
tst: '2021-01-02T05:25:00.000Z',
})
).toEqual(true)
})
it('should return true (case 2 in pseudocode)', () => {
expect(
getIsHfpRowNextDay({
journeyStartTime: '00:05',
oday: '2021-01-01',
tst: '2021-01-02T00:10:00.000Z',
})
).toEqual(true)
})
it('should return false (case 3 in pseudocode)', () => {
expect(
getIsHfpRowNextDay({
journeyStartTime: '23:55',
oday: '2021-01-01',
tst: '2021-01-02T00:05:00.000Z',
})
).toEqual(false)
})
})
Metadata
Metadata
Assignees
Labels
No labels