40 lines
1.2 KiB
PHP
40 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace swf2ass;
|
|
|
|
|
|
abstract class Utils {
|
|
|
|
static function timeToStamp($time) {
|
|
//global $offset;
|
|
//$time += $offset;
|
|
$time = max(0, $time);
|
|
$hours = floor($time / 3600);
|
|
$time = $time - $hours * 3600;
|
|
$minutes = floor($time / 60);
|
|
$seconds = $time - $minutes * 60;
|
|
$s = explode(".", strval(round($seconds, 2)));
|
|
//$s = explode(".", strval(round($seconds, 4)));
|
|
if (!isset($s[1])) {
|
|
$s[1] = 0;
|
|
}
|
|
//return $hours . ":" . str_pad($minutes, 2, "0", STR_PAD_LEFT).':'.str_pad($s[0], 2, "0", STR_PAD_LEFT) . "." . str_pad($s[1], 4, "0", STR_PAD_RIGHT);
|
|
return $hours . ":" . str_pad($minutes, 2, "0", STR_PAD_LEFT) . ':' . str_pad($s[0], 2, "0", STR_PAD_LEFT) . "." . str_pad($s[1], 2, "0", STR_PAD_RIGHT);
|
|
}
|
|
|
|
static function padHex($h, $l = 2) {
|
|
return str_pad($h, $l, "0", STR_PAD_LEFT);
|
|
}
|
|
|
|
static function dump_element(\DOMElement $element) {
|
|
var_dump($element->ownerDocument->saveXML($element));
|
|
}
|
|
|
|
static function bin2binary($bin) {
|
|
return gmp_strval(gmp_init(bin2hex($bin), 16), 2);
|
|
}
|
|
|
|
static function binary2dec($bin) {
|
|
return gmp_intval(gmp_init($bin, 2));
|
|
}
|
|
} |