@romanenko-dev/simple-timestamp
TypeScript icon, indicating that this package has built-in type declarations

1.0.7 • Public • Published

Simple Timestamp

Introduction

The Simple Timestamp library provides a set of functions and a custom component for formatting and displaying timestamps in various formats. It allows you to easily display date in relative, time, and short formats.

Installation

You can install the Simple Timestamp library via npm:

npm install @romanenko.pavlo/simple-timestamp

Components

SimpleTimestamp Component

The SimpleTimestamp component is a custom LitElement component for displaying formatted timestamps.

Attributes

  • value: String - ISO 8601 timestamp value to be displayed.
  • locale: String - The locale for formatting. Default is the user's browser locale.
  • timezone: String - The timezone to use for formatting. Default is the user's browser timezone.
  • label: String - A label to display before the timestamp.

Functions

formatTime(value: Date, locale: string, timezone: string): string

Formats a given date into a time format (e.g., '3:30 PM').

Parameters

  • value: Date - The date to format.
  • locale: String - The locale for formatting.
  • timezone: String - The timezone to use for formatting.

formatShortDate(value: Date, locale: string, timezone: string): string

Formats a given date into a short date format (e.g., 'Mar 29, 21').

Parameters

  • value: Date - The date to format.
  • locale: String - The locale for formatting.
  • timezone: String - The timezone to use for formatting.

formatRelativeDate(value: Date, locale: string): string

Formats a given date into a relative date format (e.g., '2 days ago').

Parameters

  • value: Date - The date to format.
  • locale: String - The locale for formatting.

Authors

RomanenkoStud

/@romanenko-dev/simple-timestamp/

    Package Sidebar

    Install

    npm i @romanenko-dev/simple-timestamp

    Weekly Downloads

    1

    Version

    1.0.7

    License

    ISC

    Unpacked Size

    52.8 kB

    Total Files

    22

    Last publish

    Collaborators

    • romanenko-dev