Options
All
  • Public
  • Public/Protected
  • All
Menu

External module format

Introduction

In many cases you'll want to create text output with numeric content, dates or time. On the other hand, you might want to parse numeric- or datetime values from files. To ensure the correct formatting, you can use the piweb.format module.

import * as piweb from 'piweb';
import drawing = piweb.format;

Index

Type aliases

DateKind

DateKind: "assumeUtc" | "assumeLocal"

When parsing a date without a specified time zone, the DateKind parameter determines which time zone the date has.

assumeLocal

The represented time will be interpreted as local time.

assumeUTC

The represented time will be interpreted as UTC.

Variables

Private provider

provider: any = require.binding('FormatProvider')

Functions

formatDate

  • Converts the specified date to its string representation using the specified format string and the culture specific format information.

    Parameters

    • date: Date

      The date to format.

    • Optional offsetHours: number

      The number of hours about which to offset the date.

    • Optional format: string

      The format string that tells how to format the date. Please refer to the .Net date and time format specification for a complete list of possible format strings.

    • Optional culture: CultureInfoDescription

    Returns string

formatNumber

  • Converts the specified value to its string representation using the specified format string and the culture specific format information.

    Parameters

    • value: number

      The number to format.

    • formatString: string

      The format string that tells how to format the number. Please refer to the .Net number format specification for a complete list of possible format strings.

    • Optional culture: CultureInfoDescription

      The culture to use for formatting. The function will use the invariant culture by default.

    Returns string

Private mapDateKind

  • mapDateKind(dateKind: DateKind): DateKindId.assumeLocal | DateKindId.assumeUtc
  • Parameters

    Returns DateKindId.assumeLocal | DateKindId.assumeUtc

parseDate

  • Converts the specified string to its Date equivalent by using culture specific format information and formatting style.

    Parameters

    • str: string

      The string to parse

    • Optional culture: CultureInfoDescription

      The culture to use for parsing. The function will use the invariant culture by default.

    • Default value dateKind: DateKind = "assumeLocal"

      The date kind to use for parsing.

    Returns Date

parseDateExact

  • Converts the specified string to its Date equivalent by using culture specific format information and formatting style.

    Parameters

    • str: string

      The string to parse

    • Optional format: string

      The format string that tells how to interpret the date. Please refer to the .Net date and time format specification for a complete list of possible format strings.

    • Optional culture: CultureInfoDescription

      The culture to use for parsing. The function will use the invariant culture by default.

    • Default value dateKind: DateKind = "assumeLocal"

      The date kind to use for parsing.

    Returns Date

parseNumber

  • Converts the specified string representation of a number in a specified culture specific format to its number equivalent. The function will return NaN in case parsing wasn't possible.

    Parameters

    • str: string

      The string to parse.

    • Optional culture: CultureInfoDescription

      The culture to use for parsing. The function will use the invariant culture by default.

    Returns number

Generated using TypeDoc