carbon-ts
TypeScript icon, indicating that this package has built-in type declarations

3.0.0 • Public • Published

Carbon ts

A library to simplify handling dates and times in TypeScript.

Usage

Installation

npm i carbon-ts

Create an instance

import {TimeZoneEnum, LocaleEnum, DateTime} from "carbon-ts";

// With default time zone and locale
var dateTime = DateTime.Now();


// With custom timezone and default locale
var dateTime = DateTime.now(TimeZoneEnum.enUS)

// With custom timezone and locale
var dateTime = DateTime.now(TimeZoneEnum.AmericaMonterrey, LocaleEnum.enUS);

// Add a day
dateTime.addDay();

// Difference in seconds.

const diff = dateTime.diffInSeconds(otherDateTime)

// Format a date

console.log(dateTime.toFormat("YYYY-MM-DD HH:mm:ss"))
// Use DateTimeFormatEnum as reference

export enum DateTimeFormatEnum {
    FullYear= "YYYY",
    TwoDigitsYear = "YY",
    NameMonth = "MMN",
    TwoDigitsMonth = "MM",
    Month = "M",
    NameDay = "DDD",
    TwoDigitsDay = "dd",
    Day = "d",
    TwentyFourHour = "HH",
    TwoDigitsHour = "hh",
    Hour = "h",
    TwoDigitsMinute = "mm",
    Minute = "m",
    TwoDigitsSecond = "ss",
    Second = "s"
}

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
3.0.00latest

Version History

VersionDownloads (Last 7 Days)Published
3.0.00
2.2.00
2.1.20
2.1.10
2.1.00
2.0.20
2.0.10
2.0.1-30
2.0.1-20
2.0.1-10
2.0.1-00
2.0.00

Package Sidebar

Install

npm i carbon-ts

Weekly Downloads

0

Version

3.0.0

License

MIT

Unpacked Size

101 kB

Total Files

17

Last publish

Collaborators

  • joc-luis