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

ect-date-formatter

v1.18.1

Published

An Ivy compiled package for formatting dates

Downloads

13

Readme

ECT Date Formatter

This library was generated with Angular CLI version 18.0.0.

Description

This is a date formatter service which is ESM2022, FESM2022, ESM2020, FESM2020 and FESM2015 compatible. Truth be told this library was put together after using other non-Ivy compiled packages previously, and found those packages to be a struggle to deal with in major version upgrades of the Angular framework. In the end, this library was created after those frustrations.

Usage

Add the EctDateFormatter service to your Modules' or AppComponent's Providers list, then inject the service into the constructor of your class.

For example:

import { Component } from '@angular/core';

import { EctDateFormatterService } from 'ect-date-formatter';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: [ './app.component.css' ],
  providers: [ EctDateFormatter ]
})
export class AppComponent {
  
  public isoDate = '';
  public isoDateAndTime = '';
  public isoTime = '';
  public formattedDate = '';
  public formattedTime = '';

  constructor(private dateFormatter: EctDateFormatter) {
    const sampleDate = new Date(2023, 2, 28, 9, 15, 0);
    this.isoDate = this.dateFormatter.getISO8601DateFormat(sampleDate);
    this.isoDateAndTime = this.dateFormatter.getISO8601DateAndTimeFormat(sampleDate);
    this.isoTime = this.dateFormatter.getISO8601TimeFormat(sampleDate);
    this.formattedDate = this.dateFormatter.formatDate(sampleDate, 'dddd dd MMMM yyyy');
    this.formattedTime = this.dateFormatter.formatTime(sampleDate, 'HH:MI:SS');
  }

}

In the above example, the property values set are as follows:

  • isoDate = '2023-03-28'
  • isoDateAndTime = '2023-03-28T09:15:00'
  • isoTime = '09:15:00'
  • formattedDate = 'Tuesday 28 March 2023'
  • formattedTime = '09:15:00'

After installing the packages, add the EctDateFormatter service to your Modules' or AppComponent's Providers list, then inject the service into the constructor of your class or component.

Functions

IEctDateFormatterService exposes the following functions:

  • getISO8601DateFormat(date: Date): string
  • getISO8601TimeFormat(date: Date): string
  • getISO8601DateAndTimeFormat(date: Date): string
  • formatDate(date: Date, format: string): string
  • formatTime(date: Date, format: string): string

Date format characters

In the formatDate function, the format argument accepts the following characters with their definition:

  • yy/YY: Two-digit year, e.g. 21
  • yyyy/YYYY: Four-digit year, e.g. 2021
  • m/M: One-digit month for months below 10, e.g. 3
  • mm/MM: Two-digit month, e.g. 03
  • mmm/MMM: Three-letter abbreviation for month, e.g. Mar
  • mmmm/MMMM: Month spelled out in full, e.g. March
  • d/D: One-digit day of the month for days below 10, e.g. 2
  • dd/DD: Two-digit day of the month, e.g. 02
  • ddd/DDD: Three-letter abbreviation for day of the week, e.g. Fri
  • dddd/DDDD: Day of the week spelled out in full, e.g. Friday

Time format characters

In the formatTime function, the format argument accepts the following characters with their definition:

  • h: Hour to 1 digit on 12 hour clock - without leading 0
  • hh: Hour to 2 digits on 12 hour clock - with leading 0
  • H: Hour to 1 digit on 24 hour clock - without leading 0
  • HH: Hour to 2 digits on 24 hour clock - with leading 0
  • m: Minute to 1 digit - without leading 0
  • mm/mi/MI: Minute to 2 digits - with leading 0
  • s/S: Second to 1 digit - without leading 0
  • ss/SS: Second to 2 digits - with leading 0
  • f/F: Tenth of a second e.g. 2009-06-15T13:45:30.6170000 -> 6
  • ff/FF: Hundredths of a second e.g. 2009-06-15T13:45:30.6170000 -> 61
  • fff/FFF: Milliseconds e.g. 6/15/2009 13:45:30.617 -> 617
  • ffff/FFFF: Ten thousandths of a second e.g. 2009-06-15T13:45:30.6175000 -> 6175
  • fffff/FFFFF: Hundred thousandths of a second e.g. 2009-06-15T13:45:30.6175400 -> 61754
  • ffffff/FFFFFF: Millionths of a second e.g. 2009-06-15T13:45:30.6175420 -> 617542
  • t/T: First character of AM/PM
  • tt/TT: Both characters of AM/PM

Dependencies

None

Cost

If you find some benefit from using this package, please consider the time it took to put this together, and why not buy me a coffee? Goodness only knows that most of us would not function without coffee. All donations very much welcomed: (https://www.buymeacoffee.com/exoduscloudtech)

Further help

To get more help on the this ECT Date Formatter, please visit (https://angular-grid.net/free/ect-date-formatter)