Current Year Utility

0.2.1 · abandoned · verified Sun Apr 19

The `year` package is a simple JavaScript utility designed to retrieve the current year, formatted as either two or four digits. Its primary function is to return `YYYY` by default or `YY` when explicitly requested. The current version, 0.2.1, was last updated in 2014, making it effectively abandoned and unmaintained. As such, there is no active release cadence, and it lacks support for modern JavaScript features like ESM. It differentiates itself through its extreme simplicity and minimal footprint, although modern alternatives offer more robust date formatting and are actively maintained. It targets Node.js environments version 0.8 and above, reflecting its age.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to import the `year` utility and use it to get the current year in both two-digit and four-digit formats.

const year = require('year');

// Get the current year (e.g., 2014 when this was published)
const fullYear = year();
console.log(`Current full year: ${fullYear}`);

// Get the current year in 4-digit format (explicitly)
const explicitFullYear = year('yyyy');
console.log(`Explicit full year: ${explicitFullYear}`);

// Get the current year in 2-digit format
const twoDigitYear = year('yy');
console.log(`Two-digit year: ${twoDigitYear}`);

// Example using current date to demonstrate expected output (since 'year' is fixed to 2014 in examples)
const actualCurrentYear = new Date().getFullYear();
console.log(`Actual current year (YYYY): ${actualCurrentYear}`);
console.log(`Actual current year (YY): ${String(actualCurrentYear).slice(-2)}`);

view raw JSON →