PageRenderTime 32ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

/js/lib/Socket.IO-node/support/socket.io-client/lib/vendor/web-socket-js/flash-src/com/hurlant/util/der/UTCTime.as

http://github.com/onedayitwillmake/RealtimeMultiplayerNodeJs
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. */
  9. package com.hurlant.util.der
  10. {
  11. import flash.utils.ByteArray;
  12. public class UTCTime implements IAsn1Type
  13. {
  14. protected var type:uint;
  15. protected var len:uint;
  16. public var date:Date;
  17. public function UTCTime(type:uint, len:uint)
  18. {
  19. this.type = type;
  20. this.len = len;
  21. }
  22. public function getLength():uint
  23. {
  24. return len;
  25. }
  26. public function getType():uint
  27. {
  28. return type;
  29. }
  30. public function setUTCTime(str:String):void {
  31. var year:uint = parseInt(str.substr(0, 2));
  32. if (year<50) {
  33. year+=2000;
  34. } else {
  35. year+=1900;
  36. }
  37. var month:uint = parseInt(str.substr(2,2));
  38. var day:uint = parseInt(str.substr(4,2));
  39. var hour:uint = parseInt(str.substr(6,2));
  40. var minute:uint = parseInt(str.substr(8,2));
  41. // XXX this could be off by up to a day. parse the rest. someday.
  42. date = new Date(year, month-1, day, hour, minute);
  43. }
  44. public function toString():String {
  45. return DER.indent+"UTCTime["+type+"]["+len+"]["+date+"]";
  46. }
  47. public function toDER():ByteArray {
  48. return null // XXX not implemented
  49. }
  50. }
  51. }