ASN1C C# Runtime Library  7.5
Static Public Member Functions | Public Attributes | List of all members
Asn1TimeUtil Class Reference
Inheritance diagram for Asn1TimeUtil:
Asn1PerTime

Static Public Member Functions

static String ConvertToDER (String timeValue)
 
static String DecodeDate (Asn1OerDecodeBuffer source, int flags)
 
static System.String DecodeDate (Asn1PerDecodeBuffer source, int flags)
 
static String DecodeDateTime (Asn1OerDecodeBuffer source, int flags)
 
static System.String DecodeDateTime (Asn1PerDecodeBuffer source, int flags)
 
static String DecodeDuration (Asn1OerDecodeBuffer buffer)
 
static System.String DecodeDuration (Asn1PerDecodeBuffer source, bool recurring)
 
static String DecodeTime (Asn1OerDecodeBuffer buffer, int flags)
 
static System.String DecodeTime (Asn1PerDecodeBuffer source, int flags)
 
static void EncodeDate (Asn1OerEncodeBuffer encoder, String value, int flags)
 
static void EncodeDate (Asn1PerEncoder encoder, System.String val, int flags)
 
static void EncodeDateTime (Asn1OerEncodeBuffer buffer, String value, int flags)
 
static void EncodeDateTime (Asn1PerEncoder encoder, System.String val, int flags)
 
static void EncodeDuration (Asn1OerEncodeBuffer buffer, String value)
 
static void EncodeDuration (Asn1PerEncoder encoder, System.String val, bool recurring)
 
static void EncodeTime (Asn1OerEncodeBuffer buffer, String value, int flags)
 
static void EncodeTime (Asn1PerEncoder encoder, System.String val, 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:

Member Function Documentation

◆ ConvertToDER()

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.

References Asn1DecodeBitBuffer.DecodeBit(), Asn1OerDecodeBuffer.DecodeIntSigned(), and Asn1OerDecodeBuffer.DecodeIntUnsigned().

Referenced by Asn1Duration.Asn1Duration(), and Asn1Time.Asn1Time().

◆ DecodeDate() [1/2]

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

Referenced by Asn1Date.Encode().

◆ DecodeDate() [2/2]

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

◆ DecodeDateTime() [1/2]

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
flagsIndicates 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

Referenced by Asn1DateTime.Encode().

◆ DecodeDateTime() [2/2]

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
flagsIndicates 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

References Asn1PerDecodeBuffer.DecodeBit(), Asn1PerDecodeBuffer.DecodeConsWholeNumber(), and Asn1Integer.DecodeValue().

◆ DecodeDuration() [1/2]

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"

Referenced by Asn1Duration.Encode().

◆ DecodeDuration() [2/2]

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
recurringtrue if the duration is a recurring duration
Returns

References Asn1PerDecodeBuffer.DecodeBit(), Asn1PerDecodeBuffer.DecodeConsWholeNumber(), and Asn1Integer.DecodeValue().

◆ DecodeTime() [1/2]

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
flagsIndicates the expected fields.

References Asn1Integer.DecodeValue().

Referenced by Asn1TimeOfDay.Encode().

◆ DecodeTime() [2/2]

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
flagsIndicates the expected fields.
Returns

References Asn1OerEncodeBuffer.EncodeIntSigned(), and Asn1OerEncodeBuffer.EncodeIntUnsigned().

◆ EncodeDate() [1/2]

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
flagsMust have YEAR set.

Referenced by Asn1Date.Encode().

◆ EncodeDate() [2/2]

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

References Asn1PerEncoder.EncodeInt(), and Asn1Integer.EncodeValue().

◆ EncodeDateTime() [1/2]

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".

References Asn1OerEncodeBuffer.EncodeIntUnsigned().

◆ EncodeDateTime() [2/2]

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

References Asn1PerEncoder.EncodeBit(), Asn1PerEncoder.EncodeInt(), and Asn1Integer.EncodeValue().

◆ EncodeDuration() [1/2]

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
valueThe duration

References Asn1OerEncodeBuffer.EncodeIntSigned(), and Asn1OerEncodeBuffer.EncodeIntUnsigned().

◆ EncodeDuration() [2/2]

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
valThe duration
recurringtrue if value represents a recurring duration.

References Asn1PerEncoder.EncodeBit(), Asn1PerEncoder.EncodeConsWholeNumber(), Asn1PerEncoder.EncodeInt(), and Asn1Integer.EncodeValue().

◆ EncodeTime() [1/2]

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
flagsIndicates the property constraints on the TIME type

References Asn1PerEncoder.EncodeInt(), and Asn1Integer.EncodeValue().

◆ EncodeTime() [2/2]

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

Member Data Documentation

◆ ANY

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.

◆ CENTURY

const int CENTURY = 0x4000

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

◆ DIFF

const int DIFF = 0x0020

Indicates a time includes a timezone difference from UTC.

DIFF and UTC should never appear together.

◆ DURATION

const int DURATION = 0x0010

Indicates a duration.

No other flags should be used with DURATION.

◆ FRACTION

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

◆ UTC

const int UTC = 0x0040

Indicates a time is UTC. Its string format includes the 'Z' timezone designator.

◆ WEEK

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.