File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1313
1414use Doctrine \Common \Collections \Collection ;
1515use Doctrine \Common \Collections \ArrayCollection ;
16+ use FOS \UserBundle \Util \DateUtil ;
1617
1718/**
1819 * Storage agnostic user object
@@ -317,7 +318,7 @@ public function isAccountNonExpired()
317318 return false ;
318319 }
319320
320- if (null !== $ this ->expiresAt && $ this ->expiresAt ->getTimestamp () < time () ) {
321+ if (null !== $ this ->expiresAt && DateUtil:: getSeconds ( $ this ->expiresAt ->diff ( new \ DateTime ())) <= 0 ) {
321322 return false ;
322323 }
323324
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /*
4+ * This file is part of the FOSUserBundle package.
5+ *
6+ * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
7+ *
8+ * For the full copyright and license information, please view the LICENSE
9+ * file that was distributed with this source code.
10+ */
11+
12+ namespace FOS \UserBundle \Tests \Util ;
13+
14+ use FOS \UserBundle \Util \DateUtil ;
15+
16+ class DateUtilTest extends \PHPUnit_Framework_TestCase
17+ {
18+ public function testGetSeconds ()
19+ {
20+ $ this ->assertEquals (86400 , DateUtil::getSeconds (new \DateInterval ('P1D ' )));
21+ }
22+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /*
4+ * This file is part of the FOSUserBundle package.
5+ *
6+ * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
7+ *
8+ * For the full copyright and license information, please view the LICENSE
9+ * file that was distributed with this source code.
10+ */
11+
12+ namespace FOS \UserBundle \Util ;
13+
14+ class DateUtil
15+ {
16+ /**
17+ * @param \DateInterval $interval
18+ *
19+ * @return int
20+ */
21+ public static function getSeconds (\DateInterval $ interval )
22+ {
23+ $ datetime = new \DateTime ('@0 ' );
24+
25+ return $ datetime ->add ($ interval )->getTimestamp ();
26+ }
27+ }
You can’t perform that action at this time.
0 commit comments