blob: 4e496861075a86aa20227b617202ef3d21cbab9d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
/**
* UTCTime
*
* An ASN1 type for UTCTime, represented as a Date
* Copyright (c) 2007 Henri Torgemane
*
* See LICENSE.txt for full license information.
*/
package com.hurlant.util.der
{
import flash.utils.ByteArray;
public class UTCTime implements IAsn1Type
{
protected var type:uint;
protected var len:uint;
public var date:Date;
public function UTCTime(type:uint, len:uint)
{
this.type = type;
this.len = len;
}
public function getLength():uint
{
return len;
}
public function getType():uint
{
return type;
}
public function setUTCTime(str:String):void {
var year:uint = parseInt(str.substr(0, 2));
if (year<50) {
year+=2000;
} else {
year+=1900;
}
var month:uint = parseInt(str.substr(2,2));
var day:uint = parseInt(str.substr(4,2));
var hour:uint = parseInt(str.substr(6,2));
var minute:uint = parseInt(str.substr(8,2));
// XXX this could be off by up to a day. parse the rest. someday.
date = new Date(year, month-1, day, hour, minute);
}
public function toString():String {
return DER.indent+"UTCTime["+type+"]["+len+"]["+date+"]";
}
public function toDER():ByteArray {
return null // XXX not implemented
}
}
}
|