Skip to content

Missing microseconds in Time difference #584

Open

Description

@MicaelJarniac

https://github.com/sdispater/pendulum/blob/8012a7e8600c2348f1978eebb22fdd2535a8cca9/pendulum/time.py#L212-L218

I believe that self.microsecond and dt.microsecond are being ignored when calculating the difference.

Maybe it should be something like:

 us1 = (
     self.hour * SECS_PER_HOUR + self.minute * SECS_PER_MIN + self.second
 ) * USECS_PER_SEC + self.microsecond
 
 us2 = (
     dt.hour * SECS_PER_HOUR + dt.minute * SECS_PER_MIN + dt.second
 ) * USECS_PER_SEC + dt.microsecond

Also, it does seem to me like this could go on its own method:

def microsecond_total(self) -> int:
    return (
        self.hour * SECS_PER_HOUR + self.minute * SECS_PER_MIN + self.second
    ) * USECS_PER_SEC + self.microsecond

Activity

  1. changed the title [-]Missing millis in Time comparison[/-] [+]Missing microseconds in Time comparison[/+] on Nov 27, 2021
  2. changed the title [-]Missing microseconds in Time comparison[/-] [+]Missing microseconds in Time difference[/+] on Nov 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions