Skip to content

Commit

Permalink
Fix exception
Browse files Browse the repository at this point in the history
  • Loading branch information
mantas-done committed Jan 16, 2024
1 parent 66ece9b commit 7a5e337
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Code/Converters/CsvConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ public function fileContentToInternalFormat($file_content, $original_file_conten
}
if ($is_start_time && is_numeric($data[1][0])) {
for ($i = $start; $i < count($data); $i++) {
if (!is_numeric($data[$i][0])) {
throw new UserException("Can't parse this timestamp: " . $data[$i][0]);
}
$data[$i][0] = number_format($data[$i][0], 3, '.', '');
}
}
Expand Down
13 changes: 13 additions & 0 deletions tests/formats/CsvTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,17 @@ public function testNoDecimal()

$this->assertInternalFormatsEqual($expected_internal_format, $actual_internal_format);
}

public function testWrongTimestamp()
{
$this->expectException(UserException::class);

$string = <<<TEXT
998.76,1000.79,Here's a little short demo of it.
1004.51,1.010.366,"So basically what you're seeing here, everything, all of these screenshots were made with default Twenty Twenty-Four."
1.010.368,1.018.458,"and just editing through the site editor. You can see you can make portfolios, you can make business sites."
TEXT;
Subtitles::loadFromString($string)->getInternalFormat();

}
}

0 comments on commit 7a5e337

Please sign in to comment.