npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

thirteen-months-date

v1.0.9

Published

Converts the JavaScript Date() to a 13 month date, based on the International Fixed Calendar https://en.wikipedia.org/wiki/International_Fixed_Calendar

Downloads

24

Readme

ThirteenMonthsDate

Description

ThirteenMonthsDate is a JavaScript class that implements a 13-month calendar system. This calendar system divides the year into 13 months of 28 days each, with an additional "Intercalary Day" added to leap years. The class provides functionality similar to the native JavaScript Date object, but adjusted for the 13-month calendar system (International Fixed Calendar).

Features

  • Implements a 13-month calendar system
  • Handles leap years with an Intercalary Day
  • Provides methods similar to the native JavaScript Date object
  • Supports both local and UTC time operations

Installation

Use the package manager npm to install thirteen-months-date.

npm install thirteen-months-date

Usage

Creating a ThirteenMonthsDate Object

You can create a ThirteenMonthsDate object in several ways:

// Current date and time
const date1 = new ThirteenMonthsDate();

// From a timestamp
const date2 = new ThirteenMonthsDate(1632145200000);

// From a (12 months 'Gregorian') date(time) string 
const date3 = new ThirteenMonthsDate("2023-12-31");

// From (12 months 'Gregorian') year, month, day, hour, minute, second, millisecond
const date4 = new ThirteenMonthsDate(2023, 5, 15, 12, 30, 0, 0);

Methods

The ThirteenMonthsDate class provides methods similar to the native Date object, including:

  • getDate(), getUTCDate()
  • getDay(), getUTCDay()
  • getFullYear(), getUTCFullYear()
  • getHours(), getUTCHours()
  • getMilliseconds(), getUTCMilliseconds()
  • getMinutes(), getUTCMinutes()
  • getMonth(), getUTCMonth()
  • getSeconds(), getUTCSeconds()
  • getTime(), getTimezoneOffset(), getYear()
  • setDate(), setFullYear(), setHours(), setMilliseconds(), setMinutes(), setMonth(), setSeconds(), setTime(), setYear()

Additionally, it provides some unique methods:

  • getMonthName(), getUTCMonthName(): Get the name of the month
  • isIntercalaryDay(), isUTCIntercalaryDay(): Check if the date is an Intercalary Day
  • getGregorianDateString(), getGregorianUTCDateString(): Get the DateString in the 12 months 'Gregorian' format

Formatting Methods

The class includes various methods for formatting the date:

  • toDateString()
  • toISOString()
  • toLocaleDateString()
  • toLocaleString()
  • toLocaleTimeString()
  • toString()
  • toTimeString()
  • toUTCString()

Static Methods

  • ThirteenMonthsDate.now(): Returns the current timestamp

Examples


import ThirteenMonthsDate from 'thirteen-months-date';

let date = new ThirteenMonthsDate(2023, 5, 16);

console.log('Local Gregorian DateString:', date.getGregorianDateString());
// Output: Local Gregorian DateString: Fri Jun 16 2023 00:00:00 GMT+0200 (Central European Summer Time)

console.log('UTC Gregorian DateString:', date.getGregorianUTCDateString());
// Output: UTC Gregorian DateString: Thu, 15 Jun 2023 22:00:00 GMT

console.log('Local Date:', date.getDate());
// Output: Local Date: 27

console.log('UTC Date:', date.getUTCDate());
// Output: UTC Date: 26

console.log('Local Month:', date.getMonth(), date.getMonthName());
// Output: Local Month: 5 June

console.log('UTC Month:', date.getUTCMonth(), date.monthNames[date.getUTCMonth()]);
// Output: UTC Month: 5 June

console.log('ToString:', date.toString());
// Output: ToString: Fri Jun 27 2023 00:00:00 GMT+0200 (Central European Summer Time)

console.log('ToUTCString:', date.toUTCString());
// Output: ToUTCString: Thu, 26 Jun 2023 22:00:00 GMT


date = new ThirteenMonthsDate("2023-12-31:00:30");

console.log('Local Gregorian DateString:', date.getGregorianDateString());
// Output: Local Gregorian DateString: Sun Dec 31 2023 00:30:00 GMT+0100 (Central European Standard Time)

console.log('UTC Gregorian DateString:', date.getGregorianUTCDateString());
// Output: UTC Gregorian DateString: Sat, 30 Dec 2023 23:30:00 GMT

console.log('Local Date:', date.getDate());
// Output: Local Date: 1

console.log('UTC Date:', date.getUTCDate());
// Output: UTC Date: 28

console.log('Local Month:', date.getMonth(), date.getMonthName());
// Output: Local Month: 13 Intercalary

console.log('UTC Month:', date.getUTCMonth(), date.monthNames[date.getUTCMonth()]);
// Output: UTC Month: 12 Undecember

console.log('ToString:', date.toString());
// Output: ToString: Sun Int 1 2023 00:30:00 GMT+0100 (Central European Standard Time)

console.log('ToUTCString:', date.toUTCString());
// Output: ToUTCString: Sat, 28 Und 2023 23:30:00 GMT

Note

This implementation assumes that the Intercalary Day is added as the 169th day of a leap year (June 18th in the Gregorian calendar). The behavior of this class may differ from standard calendar implementations, especially around leap years and date calculations.

For more information about the theory behind this calendar, see this Wikipedia page