ASN1C C# Runtime Library  7.4
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 System.String DecodeDate (Asn1PerDecodeBuffer source, int flags)
 
static System.String DecodeDateTime (Asn1PerDecodeBuffer source, int flags)
 
static System.String DecodeDuration (Asn1PerDecodeBuffer source, bool recurring)
 
static System.String DecodeTime (Asn1PerDecodeBuffer source, int flags)
 
static void EncodeDate (Asn1PerEncoder encoder, System.String val, int flags)
 
static void EncodeDateTime (Asn1PerEncoder encoder, System.String val, int flags)
 
static void EncodeDuration (Asn1PerEncoder encoder, System.String val, bool recurring)
 
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 Asn1Integer.DecodeValue().

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

◆ DecodeDate()

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

Referenced by Asn1Date.Encode().

◆ DecodeDateTime()

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().

Referenced by Asn1DateTime.Encode().

◆ DecodeDuration()

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().

Referenced by Asn1Duration.Encode().

◆ DecodeTime()

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 Asn1PerEncoder.EncodeInt(), and Asn1Integer.EncodeValue().

Referenced by Asn1TimeOfDay.Encode().

◆ EncodeDate()

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().

Referenced by Asn1Date.Encode().

◆ EncodeDateTime()

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()

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()

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.