private static function fromInterval($value)
    {
        if (is_null($value)) {
            return null;
        }
        $res = preg_match(
            "/(?P<sign>\-)?(?:(?P<years>\d+) years? ?)?(?:(?P<months>\d+) mons? ?)?(?:(?P<days>\d+) days? ?)?" .
            "(?:(?P<h>\d+):(?P<m>\d+):(?P<s>\d+))?(?:\.(?P<ms>\d+))?/",
            $value,
            $match
        );
        if (!$res) {
            throw new Exception('Malformed interval');
        }
        $match += ['years' => 0, 'months' => 0, 'days' => 0, 'h' => 0, 'm' => 0, 's' => 0];

        $res = $match['years'] * 31557600
            + $match['months'] * 2592000
            + $match['days'] * 86400
            + $match['h'] * 3600
            + $match['m'] * 60
            + $match['s'];

        if (!empty($match['ms'])) {
            $res = floatval($res) + floatval($match['ms'] / intval('1' . str_repeat('0', strlen($match['ms']))));
        }

        if (isset($match['sign']) && $match['sign'] == '-') {
            $res *= -1;
        }

        return $res;
    }