File

projects/wms-framework/src/lib/baseframework/SupportDateTime.ts

Description

Stores constant values for legacy DateTime.

Index

Properties
Methods
Accessors

Constructor

Private constructor()

Creates an instance of SupportDateTime.

NOTE: Private constructor to avoid instances of this class.

Properties

Private Static Readonly _maxValue
Default value : new Date('9999-12-31T23:59:59.9999999')

Stores the legacy maximum value.

Private Static Readonly _minValue
Default value : new Date('0001-01-01T00:00:00.000')

Stores the legacy minimum value.

Static Readonly MinValueTicksUtc
Default value : -62135596800000

Legacy minimum value in ticks since UNIX Epoch.

Methods

Static IsMinValue
IsMinValue(value: Date)

Indicates whether the given date is the min value date

Parameters :
Name Type Optional Description
value Date No

the Date to test for

Returns : boolean

Accessors

MinValue
getMinValue()

Minimum value for legacy DateTime.

Returns : Date
MaxValue
getMaxValue()

Maximum value for legacy DateTime.

Returns : Date
export class SupportDateTime {
  /**
   * Creates an instance of SupportDateTime.
   *
   * NOTE: Private constructor to avoid instances of this class.
   *
   * @memberof SupportDateTime
   */
  private constructor() {
    // Private constructor to avoid instances of this class.
  }

  /**
   * Stores the legacy minimum value.
   *
   * @private
   * @static
   * @memberof LegacyDateTime
   */
  private static readonly _minValue = new Date('0001-01-01T00:00:00.000');

  /**
   * Stores the legacy maximum value.
   *
   * @private
   * @static
   * @memberof LegacyDateTime
   */
  private static readonly _maxValue = new Date('9999-12-31T23:59:59.9999999');

  /**
   * Legacy minimum value in ticks since UNIX Epoch.
   *
   * @static
   * @memberof LegacyDateTime
   */
  public static readonly MinValueTicksUtc = -62135596800000;

  /**
   * Minimum value for legacy `DateTime`.
   *
   * @readonly
   * @static
   * @type {Date}
   * @memberof LegacyDateTime
   */
  public static get MinValue(): Date {
    // Returns a copy of MinValue, to avoid someone changing its value.
    return new Date(SupportDateTime._minValue.getTime());
  }

  /**
   * Indicates whether the given date is the min value date
   *
   * @static
   * @param {Date} value the Date to test for
   * @memberof SupportDateTime
   */
  public static IsMinValue(value: Date): boolean {
    return (
      value != null && value.getTime() === SupportDateTime.MinValue.getTime()
    );
  }

  /**
   * Maximum value for legacy `DateTime`.
   *
   * @readonly
   * @static
   * @type {Date}
   * @memberof LegacyDateTime
   */
  public static get MaxValue(): Date {
    // Returns a copy of MaxValue, to avoid someone changing its value.
    return new Date(SupportDateTime._maxValue.getTime());
  }
}

result-matching ""

    No results matching ""