JSPM

phane-tech-date-time-utils

1.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q28228F
  • License MIT

Pure JavaScript array utility functions

Package Exports

  • phane-tech-date-time-utils
  • phane-tech-date-time-utils/index.cjs
  • phane-tech-date-time-utils/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (phane-tech-date-time-utils) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

πŸ“¦ Kotipalli Phaneendra Kumar – Date & Time Utilities

A lightweight, dependency-minimal JavaScript module that provides safe, consistent, and reusable Date & Time helper functions.

These utilities simplify working with dates, times, months, weekdays, and financial years, handling edge cases cleanly and predictably.

Designed for frontend (Vue/React) and Node.js applications.


✨ Highlights

  • ⏰ Time formatting (12h / 24h)
  • πŸ•’ Human‑readable relative time ("few moments ago")
  • πŸ“… Month & weekday helpers (names & numbers)
  • πŸ’Ό Financial year utilities (current, offset, range)
  • 🌍 Locale‑aware formatting
  • πŸ§ͺ Jest‑friendly & predictable outputs
  • ⚑ Zero heavy dependencies

πŸ“¦ Installation

npm install phane-tech-date-time-utils

πŸš€ Import

import {
  getTime,
  getTimeAgo,
  getMonth,
  getYear,
  getMonthName,
  getDayName,
  getAllMonths,
  getAllDayNames,
  getFinancialYear,
  getFinancialYearByOffset,
  getFinancialYearsBetween,
  getMonthsBetween,
  getDateTime,
  isWeekend
} from "phane-js-datetime-utils";

πŸ“š API Reference & Examples

⏰ getTime(isRailway, date)

getTime();                     // "03:45:10 PM"
getTime(true);                 // "15:45:10"
getTime(false, "2026-01-10");  // Time for given date

πŸ•’ getTimeAgo(date)

getTimeAgo(new Date());               // "few moments ago"
getTimeAgo(Date.now() - 60000);       // "1 min ago"
getTimeAgo(Date.now() - 7200000);     // "2 hours ago"
getTimeAgo("2025-04-12");             // "x months ago"

πŸ“… getMonth / getYear

getMonth();            // 1–12
getMonth("2026-05");   // 5

getYear();             // 2026
getYear("2020-01");    // 2020

πŸ—“ getMonthName / getDayName

getMonthName(true);        // "January"
getMonthName(false);       // "Jan"

getDayName();              // "Monday"
getDayName(false);         // "Mon"

πŸ“† getAllMonths / getAllDayNames

getAllMonths();        // ["January", ...]
getAllMonths(false);   // ["Jan", ...]

getAllDayNames();      // ["Sunday", ...]
getAllDayNames(false); // ["Sun", ...]

πŸ’Ό Financial Year Helpers

getFinancialYear("2026-01-10");      // "2025-2026"
getFinancialYearByOffset(-1);        // Previous FY
getFinancialYearByOffset(1);         // Next FY

getFinancialYearsBetween(
  "2021-01-01",
  "2024-12-31"
);
// ["2020-2021","2021-2022","2022-2023","2023-2024"]

πŸ—“ Months Between Dates

getMonthsBetween("2026-01-01", "2026-04-01");
// ["January","February","March","April"]

getMonthsBetween("2026-01-01", "2026-04-01", { asNumber: true });
// [1,2,3,4]

getMonthsBetween("2026-01-01", "2026-04-01", { fullName: false });
// ["Jan","Feb","Mar","Apr"]

πŸ•° getDateTime

getDateTime();
// "10/01/2026, 03:45 PM"

getDateTime("2026-01-10", false);
// "10/01/2026"

getDateTime("2026-01-10", true, true);
// "10/01/2026, 15:45"

πŸ“Œ isWeekend

isWeekend("2026-01-11"); // true

πŸ§ͺ Testing

  • Fully compatible with Jest
  • Deterministic outputs
  • Ideal for unit & snapshot testing

πŸ“„ License

MIT