Files
oai-symfony/typo3conf/ext/youtubevideo/Classes/Evaluation/HoursMinutesSeconds.php
2026-07-03 17:53:31 +02:00

38 lines
1010 B
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace Brightside\Youtubevideo\Evaluation;
/**
* Class for field value validation/evaluation to be used in 'eval' of TCA
*/
class HoursMinutesSeconds
{
/**
* JavaScript code for client side validation/evaluation
*
* @return string JavaScript code for client side validation/evaluation
*/
public function returnFieldJS()
{
return "
var value = value.replace(/[-|_|,|.||']+/g,':');
var value = value.replace(/[^\d:]+/g,'');
var value = value.replace(/^:|:$/g, '');
var p = value.split(':'),
s = 0, m = 1;
while (p.length > 0) {
s += m * parseInt(p.pop(), 10);
m *= 60;
}
if (s > 0) {
var date = new Date(0);
date.setSeconds(s);
var value = date.toISOString().substr(11, 8);
return value;
} else {
return '';
}
";
}
}