Skip to content

Commit 3e5c620

Browse files
modified smaller scale diffIn methods to use seconds and microsecond differences rather than days (#27)
Co-authored-by: Roger Vilà <rogervila@me.com>
1 parent 9aef285 commit 3e5c620

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

python_carbon/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -441,16 +441,16 @@ def diffIn(self, unit: str, carbon: 'Carbon') -> int:
441441
return method(carbon)
442442

443443
def diffInMicroseconds(self, carbon: 'Carbon') -> int:
444-
return self.diffInSeconds(carbon) * 1000
444+
return (self._date - carbon.toDatetime()).microseconds
445445

446446
def diffInSeconds(self, carbon: 'Carbon') -> int:
447-
return self.diffInMinutes(carbon) * 60
447+
return (self._date - carbon.toDatetime()).seconds
448448

449449
def diffInMinutes(self, carbon: 'Carbon') -> int:
450-
return self.diffInHours(carbon) * 60
450+
return self.diffInSeconds(carbon) / 60
451451

452452
def diffInHours(self, carbon: 'Carbon') -> int:
453-
return self.diffInDays(carbon) * 24
453+
return self.diffInMinutes(carbon) / 60
454454

455455
def diffInDays(self, carbon: 'Carbon') -> int:
456456
return (self._date - carbon.toDatetime()).days

0 commit comments

Comments
 (0)