|
/**
* 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
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I currently hold the following qualifications (amongst others, I also studied Music Technology and Electronics, for my sins)
- MSc (Passed with distinctions), in Information Technology for E-Commerce
- BSc Hons (1st class) in Computer Science & Artificial Intelligence
Both of these at Sussex University UK.
Award(s)
I am lucky enough to have won a few awards for Zany Crazy code articles over the years
- Microsoft C# MVP 2016
- Codeproject MVP 2016
- Microsoft C# MVP 2015
- Codeproject MVP 2015
- Microsoft C# MVP 2014
- Codeproject MVP 2014
- Microsoft C# MVP 2013
- Codeproject MVP 2013
- Microsoft C# MVP 2012
- Codeproject MVP 2012
- Microsoft C# MVP 2011
- Codeproject MVP 2011
- Microsoft C# MVP 2010
- Codeproject MVP 2010
- Microsoft C# MVP 2009
- Codeproject MVP 2009
- Microsoft C# MVP 2008
- Codeproject MVP 2008
- And numerous codeproject awards which you can see over at my blog