Skip to content

Averages don't take into account milliseconds #137

@ericfrederich

Description

@ericfrederich

Averages seem to just copy the millisecond portion instead of averaging them.

For two instances of Pendulum p1 and p2 I believe it should hold that p1.average(p2) == p2.average(p1)

This is not currently the case. In fact, averaging two times that are only 1 second apart will yield one of the source times rather than a midpoint.

import pendulum
import time

p1 = pendulum.now()
time.sleep(1)
p2 = pendulum.now()

a1 = p1.average(p2)
a2 = p2.average(p1)

print(p1)
print(a1)
print(a2)
print(p2)
print(a1 == a2)
print(p1 == a1)
print(p2 == a2)

example output:

2017-08-23T12:01:32.809279-04:00
2017-08-23T12:01:32.809279-04:00
2017-08-23T12:01:33.821634-04:00
2017-08-23T12:01:33.821634-04:00
False
True
True

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions