1<?php 2/** 3 * This file is part of the FreeDSx ASN1 package. 4 * 5 * (c) Chad Sikorra <Chad.Sikorra@gmail.com> 6 * 7 * For the full copyright and license information, please view the LICENSE 8 * file that was distributed with this source code. 9 */ 10 11namespace FreeDSx\Asn1\Type; 12 13use DateTimeInterface; 14 15/** 16 * Represents a UTC Time type. 17 * 18 * @author Chad Sikorra <Chad.Sikorra@gmail.com> 19 */ 20class UtcTimeType extends AbstractTimeType 21{ 22 /** 23 * Only a 2 day year (was Y2K not a thing back then?), seconds are optional, Z or time differential. 24 */ 25 public const TIME_REGEX = '~^ 26 (\d\d) # 1 - Year 27 (\d\d) # 2 - Month 28 (\d\d) # 3 - Day 29 (\d\d) # 4 - Hour 30 (\d\d) # 5 - Minutes 31 (\d\d)? # 6 - Seconds, which are optional 32 (Z|[\+\-]\d\d\d\d) # 7 - Timezone modifier (not optional). It can either be a Z (UTC) or a time differential. 33 $~x'; 34 35 public const REGEX_MAP = [ 36 'hours' => 4, 37 'minutes' => 5, 38 'seconds' => 6, 39 'timezone' => 7, 40 ]; 41 42 protected $tagNumber = self::TAG_TYPE_UTC_TIME; 43 44 /** 45 * Valid datetime formats. 46 */ 47 protected $validDateFormats = [ 48 self::FORMAT_SECONDS, 49 self::FORMAT_MINUTES, 50 ]; 51 52 /** 53 * Valid timezone formats 54 */ 55 protected $validTzFormats = [ 56 self::TZ_UTC, 57 self::TZ_DIFF, 58 ]; 59 60 /** 61 * {@inheritdoc} 62 */ 63 public function __construct(?DateTimeInterface $dateTime = null, string $dateFormat = self::FORMAT_SECONDS, string $tzFormat = self::TZ_UTC) 64 { 65 parent::__construct($dateTime, $dateFormat, $tzFormat); 66 } 67} 68