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