Asn1TimeUtil Class Reference

Provides methods to encode and decode TIME values in various. More...

Inheritance diagram for Asn1TimeUtil:
Asn1PerTime

List of all members.

Static Public Member Functions

static String ConvertToDER (String timeValue)
static System.String DecodeDate (Asn1PerDecodeBuffer source, int flags)
static String DecodeDate (Asn1OerDecodeBuffer source, int flags)
static System.String DecodeDateTime (Asn1PerDecodeBuffer source, int flags)
static String DecodeDateTime (Asn1OerDecodeBuffer source, int flags)
static System.String DecodeDuration (Asn1PerDecodeBuffer source, bool recurring)
static String DecodeDuration (Asn1OerDecodeBuffer buffer)
static System.String DecodeTime (Asn1PerDecodeBuffer source, int flags)
static String DecodeTime (Asn1OerDecodeBuffer buffer, int flags)
static void EncodeDate (Asn1PerEncoder encoder, System.String val, int flags)
static void EncodeDate (Asn1OerEncodeBuffer encoder, String value, int flags)
static void EncodeDateTime (Asn1PerEncoder encoder, System.String val, int flags)
static void EncodeDateTime (Asn1OerEncodeBuffer buffer, String value, int flags)
static void EncodeDuration (Asn1PerEncoder encoder, System.String val, bool recurring)
static void EncodeDuration (Asn1OerEncodeBuffer buffer, String value)
static void EncodeTime (Asn1PerEncoder encoder, System.String val, int flags)
static void EncodeTime (Asn1OerEncodeBuffer buffer, String value, int flags)

Public Attributes

const int ANY = 0x8000
const int CENTURY = 0x4000
const int DIFF = 0x0020
const int DURATION = 0x0010
const int FRACTION = 0x000F
const int UTC = 0x0040
const int WEEK = 0x0800

Detailed Description

encoding rules. The application representation of the TIME value is simply a String, whose content shall be a TimeValue, as defined in X.680. Some notes on formatting: + A year/century should have a leading plus sign if and only if the year/century > 9999/99. + A year/century having 5/3 or more digits should never include leading zeros. A value with a year of 1985 has the property Year="Basic" and is formatted with only 4 digits, never more. + A year/century should never have fewer than four/two digits. This is the only case where leading zeros may be used. + When FRACTION is used to specify a number of fraction digits, the string representation must have precisely that many digits for the fraction. Note that FRACTION is not to be used with DURATION.


Member Function Documentation

static String ConvertToDER ( String  timeValue  )  [static]

Return the DER representation of a TimeValue. Given some TimeValue, this function returns a string representing the characters that should be encoded for that TimeValue when using DER.

This can be invoked for values of type TIME. Its result is not correct for values of type DATE, TIME-OF-DAY, DATE-TIME, or DURATION, all of which require removing certain characters that are not removed for values of type TIME. However, for DURATION, this function can first be used and then the leading P removed.

static System.String DecodeDate ( Asn1PerDecodeBuffer  source,
int  flags 
) [static]

Decode a date value from the given source.

This should be used for types having Basic="Date".

Parameters:
source 
flags 
Returns:
ASN.1 TimeValue representation of decoded value
static String DecodeDate ( Asn1OerDecodeBuffer  source,
int  flags 
) [static]

Decode a date value according to OER from the given source. This should be used for types having Basic="Date" and Date equal to "Y", "YM", or "YMD".

Returns:
ASN.1 TimeValue representation of decoded value
static System.String DecodeDateTime ( Asn1PerDecodeBuffer  source,
int  flags 
) [static]

Decode a date-time value from the given source.

This should be used for types having Basic="Date-Time".

Parameters:
source 
flags Indicates what fields are expected. The flags should indicate a complete date (YMD, YWD, or YD) and at least an hour component.
Returns:
The value represented as an ASN.1 TimeValue
static String DecodeDateTime ( Asn1OerDecodeBuffer  source,
int  flags 
) [static]

Decode a date-time value from the given source.

This should be used for types having Basic="Date-Time", Date equal to "Y", "YM", or "YMD", Time equal to "H", "HM", "HMS", or "HMSFn" and Local-or-UTC equal to "L", "Z", or "LD".

Parameters:
flags Indicates what fields are expected. The flags should indicate a complete date (YMD, YWD, or YD) and at least an hour component.
Returns:
The value, represented as an ASN.1 TimeValue
static System.String DecodeDuration ( Asn1PerDecodeBuffer  source,
bool  recurring 
) [static]

Decode a (possibly recurring) duration from the given source.

This should be used for types having Basic="Interval" or "Rec-Interval" and Interval-type="D"

Parameters:
source 
recurring true if the duration is a recurring duration
Returns:
static String DecodeDuration ( Asn1OerDecodeBuffer  buffer  )  [static]

Decode a duration according to OER from the given buffer. This should be used for types having Basic="Interval" and Interval-type="D"

static System.String DecodeTime ( Asn1PerDecodeBuffer  source,
int  flags 
) [static]

Decode a time value from the given source.

This should be used for types having Basic="Time".

Parameters:
source 
flags Indicates the expected fields.
Returns:
static String DecodeTime ( Asn1OerDecodeBuffer  buffer,
int  flags 
) [static]

Decode a time value according to OER from the given source. This should be used for types meeting the following: 1) Basic="Time" 2) Time is one of "H", "HM", "HMS", "HMSFn" (for some fixed n) 3) Local-or-UTF is "L", "Z", or "LD"

Parameters:
flags Indicates the expected fields.
static void EncodeDate ( Asn1PerEncoder  encoder,
System.String  val,
int  flags 
) [static]

Encode a date value according to PER, using the given.

encoder. This should be used for types having Basic="Date".

Parameters:
encoder 
val 
flags 
static void EncodeDate ( Asn1OerEncodeBuffer  encoder,
String  value,
int  flags 
) [static]

Encode a date value according to OER, using the given encoder.

This should be used for types having Basic="Date" and Date equal to "Y", "YM" or "YMD".

Parameters:
flags Must have YEAR set.
static void EncodeDateTime ( Asn1PerEncoder  encoder,
System.String  val,
int  flags 
) [static]

Encode a datetime value.

This should be used for types having Basic="Date-Time".

Parameters:
encoder 
val 
flags 
static void EncodeDateTime ( Asn1OerEncodeBuffer  buffer,
String  value,
int  flags 
) [static]

Encode a datetime value according to OER. This should be used for types having Basic="Date-Time", Date equal to "Y", "YM", or "YMD", Time equal to "H", "HM", "HMS", or "HMSFn" and Local-or-UTC equal to "L", "Z", or "LD".

static void EncodeDuration ( Asn1PerEncoder  encoder,
System.String  val,
bool  recurring 
) [static]

Encode a duration according to PER.

This should be used for types having Basic="Interval" or "Rec-Interval", and Interval-type="D".

Parameters:
encoder 
val The duration
recurring true if value represents a recurring duration.
static void EncodeDuration ( Asn1OerEncodeBuffer  buffer,
String  value 
) [static]

Encode a duration according to OER. This should be used for types having Basic="Interval" and Interval-type="D".

Parameters:
value The duration
static void EncodeTime ( Asn1PerEncoder  encoder,
System.String  val,
int  flags 
) [static]

Encode a time value.

This should be used for types having Basic="Time".

Parameters:
encoder 
val 
flags 
static void EncodeTime ( Asn1OerEncodeBuffer  buffer,
String  value,
int  flags 
) [static]

Encode a time value according to OER. This may be used only for TIME types that have been constrained so as to have an optimized encoding. This means being constrained as follows: 1) Basic=Time 2) Time is one of H, HM, HMS, HMSFn for some fixed n. 3) Local-or-UTF is one of L, Z, or LD

Parameters:
flags Indicates the property constraints on the TIME type

Member Data Documentation

const int ANY = 0x8000

For PER, when ANY is combined with CENTURY/YEAR, it indicates that the type is constrained to values with Year=Ln or NEGATIVE (as for the defined types named ANY-*), while absence of ANY indicates the type is constrained to values with Year=Basic or Proleptic.

There is a little inconsistency here, however. At present, code generation will use the DT_ANY* constants for a type that has Year=Negative, or that has Year=Ln for some n. By contrast, the defined types named ANY-* include values that have either Year=Negative or Year=L5. I think this discrepancy doesn't matter though, because PER uses the same encodings whether type includes:

  • only values with Year=Ln
  • only values with Year=L5
  • only values with Year=Negative
  • only values with Year=Negative or Year=L5

The ANY flag's presence/absence is irrelevant to OER, as OER's optimized encodings do not depend on the Year property.

const int CENTURY = 0x4000

Flags for Date properties. Each flag indicates a particular component that is required for dates.

const int DIFF = 0x0020

Indicates a time includes a timezone difference from UTC.

DIFF and UTC should never appear together.

const int DURATION = 0x0010

Indicates a duration.

No other flags should be used with DURATION.

const int FRACTION = 0x000F

This is a mask that is used to mark off the bits used for.

the number of decimal places for a fraction.

value & FRACTION = # of decimal places

const int UTC = 0x0040

Indicates a time is UTC.

Its string format includes the 'Z' timezone designator.

const int WEEK = 0x0800

Week is present.

When used for a duration (with DURATION), the following are excluded: CENTURY, YEAR, MONTH, DAY, HOURS, MINUTES, SECONDS

When used for a date/datetime (without DURATION), MONTH is excluded.