Skip to content

Instantly share code, notes, and snippets.

View t1gor's full-sized avatar
💭
I may be slow to respond.

Igor Timoshenkov t1gor

💭
I may be slow to respond.
View GitHub Profile
@drock
drock / DateTimeComparator.php
Last active September 8, 2022 15:46
A comparator object for PHPUnit to support asserting that two DateTime objects are logically equaly.
<?php
/**
* Class DateTimeComparator
*
* Custom Comparator for PHPUnit to compare two DateTime objects
* The default object comparator will report some DateTime object pairs
* as not equal even if they are canonically equal because the object
* comparator looks a exact object field values. A DateTime object
* can have multiple timezone values that represent the same timezone
* however. This comparator compares the object's UTC timestamps