3.0.0 • Published 1 month ago

carbon-ts v3.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

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"
}
3.0.0

1 month ago

2.1.2

1 month ago

2.2.0

1 month ago

2.1.1

1 month ago

2.1.0

1 month ago

2.0.2

1 month ago

2.0.1

1 month ago

2.0.1-3

1 month ago

2.0.1-2

1 month ago

2.0.1-1

1 month ago

2.0.1-0

1 month ago

2.0.0

1 month ago