Skip to content

Commit

Permalink
Merge pull request #53 from shaarli/fix/time-undefined
Browse files Browse the repository at this point in the history
Fix - time undefined variable
  • Loading branch information
ArthurHoaro authored Jun 6, 2020
2 parents 413b260 + 20813e0 commit 407171f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
3 changes: 2 additions & 1 deletion NetscapeBookmarkParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,9 @@ public function parseDate($date)
// attempt to parse a known compound date/time format
return strtotime($date);
}

// current date & time
return $time;
return time();
}

/**
Expand Down
17 changes: 17 additions & 0 deletions tests/ParseNetscapeBookmarksTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,23 @@ public function testParseUnixDates()
);
}

/**
* Parse invalid date
*/
public function testParseInvalidDates()
{
// Just to make sure that even if the CI is slow, we're fine.
$range = [time() - 5, time() + 5];

$date = $this->parser->parseDate('0');
$this->assertGreaterThanOrEqual($range[0], $date);
$this->assertLessThan($range[1], $date);

$date = $this->parser->parseDate('not a date');
$this->assertGreaterThanOrEqual($range[0], $date);
$this->assertLessThan($range[1], $date);
}

/**
* Leave links with no/empty tag as-is
*/
Expand Down

0 comments on commit 407171f

Please sign in to comment.