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

datetime-val

v1.0.5

Published

useful tools for datetime validations

Downloads

9

Readme

datetime-val

some useful tools for datetime validations.

Table of Contents

Installation

$ npm i datetime-val

Zulu Time Converter Function

The zuluTimeNow function is a JavaScript utility designed to convert the current local time to Zulu Time (Coordinated Universal Time, UTC). Zulu Time is a standardized time reference used in aviation, military, and other fields to eliminate confusion arising from different time zones.

To use the zuluTimeNow function, simply call it within your JavaScript code:

const dtnpm = require('datetime-val')
const dateTimeVal = new dtnpm() //default: de
const zuluTime = dateTimeVal.zuluTimeNow();
console.log("Zulu Time:", zuluTime);
"Zulu Time: 2023-08-28T08:34:24.492Z"

Date String to ISO Conversion Utility

The convertToISOFill function is a JavaScript utility designed to convert a given date string in a specific format into the ISO 8601 date format. The ISO 8601 format is widely recognized and used for representing dates and times in a standardized way. This utility focuses on converting a particular format of date string into its ISO equivalent.

To use the convertToISOFill function, pass the date string you want to convert as an argument:

const dateInput = "12.31.23"; // Example date string
const conversionResult = convertToISOFill(dateInput);
console.log("Conversion Result:", conversionResult);
Conversion Result: {
  valDateString: '31.12.2023',
  dateStringISO: 2023-12-31T00:00:00.000Z
}

const dateInput = "7.4.21";
Conversion Result: {
  valDateString: '07.04.2021',
  dateStringISO: 2021-04-07T00:00:00.000Z
}

const dateInput = "12.31.2023"; // Invalid format
Conversion Result: {
    valDateString: false,
    dateStringISO: false
}

Zulu Time to Local Date Format Converter

The convertFromZulu function is a JavaScript utility designed to convert a given Zulu Time (UTC) date string into a local date format, with the ability to support different country-specific date formats. This utility extracts the day, month, and year components from the Zulu Time date and formats them based on the specified country's requirements.

To use the convertFromZulu function, provide a Zulu Time (UTC) date string and, if applicable, specify the country code (e.g., 'us' or 'de') to indicate the desired local date format:

const zuluDateString = "2023-08-28T12:34:56Z"; // Example Zulu Time date string
const convertedDate = convertFromZulu(zuluDateString);
console.log("Converted Date:", convertedDate);
"Converted Date: 28.08.2023"

Convert every Data given to Zulu Time

The convertToZulu function is a JavaScript utility designed to convert a given local date string to its equivalent Zulu Time (Coordinated Universal Time, UTC) string representation. Zulu Time is widely used in aviation, military, and other applications to maintain a standardized time reference. This utility provides the flexibility to handle country-specific date formatting and conversion.

const converted = dateTimeVal.convertToZulu('2020-07-09T00:00:00.000Z');
console.log("converted:", converted);
"converted: 2020-07-09T00:00:00.000Z"
dateTimeVal.convertToZulu('1.12.2023');
"converted: 2023-12-01T00:00:00.000Z"
dateTimeVal.convertToZulu('111.12.2023');
"converted: false"