1.1.0 • Published 11 months ago

@master4n/temporal-transformer v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

@master4n/temporal-transformer

Owner Badge Package License Package Downloads

Temporal Transformer is a library that converts epoch values to human-readable dates and dates to epoch value in both the user's local timezone and GMT. The project uses the moment-timezone library to handle date and time conversions and formatting.

Features

  • Automatically detects the type of epoch (seconds, milliseconds, microseconds, nanoseconds).
  • Converts epoch values to human-readable dates.
  • Converts human-readable dates to epoch values.
  • Displays dates in both the user's local timezone and GMT.
  • User-friendly output with clear assumptions about the epoch type.

Installation

  1. Library Installation:

    npm install --save-dev @master4n/temporal-transformer

Usage

  1. Method use to convert from epoch to date:

    import { convertEpoch, EpochToDate } from @master4n/temporal-transformer
    
    const epoch = 1622547800000; // Example epoch value
    
    const data: EpochToDate = convertEpoch(epoch); // Default format 'YYYY-MM-DD HH:mm:ss' used.
    const data: EpochToDate = convertEpoch(epoch, 'YYYY-DD-MM HH:mm:ss'); // User provided formatted output
  2. Method use to convert from date object to epoch:

    import { convertDateToEpoch, DateToEpoch } from @master4n/temporal-transformer
    
    const date = new Date(); // Any date.
    const timezone = 'America/New_York'
    
    const data: DateToEpoch = convertDateToEpoch(date); // Default user timezone used for formatting.
    const data: DateToEpoch = convertDateToEpoch(date, timezone); // User provided timezone used for formatting

Credits

These definitions were written by Master4Novice.

1.1.0

11 months ago

1.0.9

11 months ago

1.0.8

11 months ago

1.0.7

11 months ago

1.0.6

11 months ago

1.0.5

11 months ago

1.0.4

11 months ago

1.0.3

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago