aholstenson / datetime-types

JavaScript and TypeScript objects for representing date, times, intervals and durations

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

datetime-types

This library provides immutable dates, times, intervals, periods and durations for JavaScript and TypeScript. These types help carry the intent of a value, instead of representing everything as a Date.

import { LocalDate, LocalTime } from 'datetime-types';

const date = LocalDate.of(2042, 10, 2);
const time = LocalTime.from({
  hour: 12,
  minute: 45
});

Status and features

This is currently an early release with only a few types without much ability to manipulate values.

Types implemented:

  • LocalDate for representing a date without a time
  • LocalTime for representing a time without a date or timezone
  • LocalDateTime for representing a date and time without a timezone
  • DayOfWeek enumeration
  • Month enumeration
  • Year for representing a single year
  • DateInterval for representing an interval between two dates

About

JavaScript and TypeScript objects for representing date, times, intervals and durations

License:MIT License


Languages

Language:TypeScript 98.6%Language:JavaScript 1.4%