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

@tchitos/datetime-picker

v16.1.0

Published

[![npm](https://img.shields.io/npm/v/@tchitos/datetime-picker.svg?maxAge=2592000?style=flat-square)](https://www.npmjs.com/package/@tchitos/datetime-picker) [![npm](https://img.shields.io/npm/dm/@tchitos/datetime-picker.svg)](https://www.npmjs.com/package

Downloads

19

Readme

Angular DateTimePickerLibrary

npm npm

Angular dateTime picker - This package supports Angular 16+ Checkout the Demo

Installation

  1. Install package from npm.
npm install @tchitos/datetimePicker --save
  1. Include DatetimePickerModule into your application.
//...
import { DatetimePickerModule } from '@tchitos/datetime-picker';

@NgModule({
  imports: [..., DatetimePickerModule]
})
export class SomeModule {}

And that's it, you can then use it in your component as:

import { FormGroup, FormBuilder } from '@angular/forms';
import { DatePickerOptions } from '@tchitos/datetime-picker';


options: DatePickerOptions = {
  placeholder: 'Start date',
  enableHour: true
};

formGroup: FormGroup;

constructor(private fb: FormBuilder) {
    this.formGroup = this.fb.group({
        date: [new Date() ]
    })
}
<form [formGroup]="formGroup">
  <ngx-datetimePicker [options]="options" formControlName="date"> </ngx-datetimePicker>
</form>

Options

Then you apply custom options in your template as:

today = new Date();
<form [formGroup]="formGroup">
  <ngx-datetimePicker formControlName="date" [minDate]="today"> </ngx-datetimePicker>
</form>

All the properties for DatePickerOptions are optional

| Name | Type | Default | Description | | :--------------------| :-------- | :------------------------- | :--------------------------------------------------------------------------------- | | minYear | number | getYear(new Date()) - 20 | minimum available and selectable year | | maxYear | number | getYear(new Date()) + 20 | maximum available and selectable year | | placeholder | string | `` | placeholder in case date model is null or undefined, example: 'Please pick a date' | | format | string | dd/MM/yyyy | date format to display in input | | formatTitle | string | LLLL yyyy | date format to change view | | formatDays | string | EEEEE | | | firstCalendarDay | number | 0 | 0 - Sunday, 1 - Monday | | locale | Locale | 0 | date-fns locale | | position | string | bottom | date-fns locale | | inputClass | string | datepicker-input | custom input CSS class to be applied | | calendarClass | string | datepicker-default | custom datepicker calendar CSS class to be applied | | scrollBarColor | string | #dfe3e9 | in case you customize you theme, here you define scroll bar color | | enableKeyboard | boolean | true | enable keyboard events | | enableHour | boolean | false | enable time picker |

For available format, formatTitle and formatDays options check out here.

You can also update your options in your template as:

import { DatePickerOptions } from '@tchitos/datetime-picker';
import * as localFR from 'date-fns/locale/fr';
import * as localUS from 'date-fns/locale/en-US';

  optionUpdate: BehaviorSubject<DatePickerOptions> = new BehaviorSubject<DatePickerOptions>({});

// options sample with default values
  options: DatePickerOptions = {
      format: 'dd/MM/yyyy',
      enableHour: true//enabling the time
    };


  changeToFrench() {
    this.options = {
      ...this.options,
      format: 'dd/MM/yyyy',// french date format is day/month/year
      locale: localFR.default // changing the datepicker's language to french
    }
    this.optionUpdate.next(this.options)
  }

  changeToEnglish() {
    this.options = {
      ...this.options,
      format: 'MM/dd/yyyy', // USA date format is month/day/year
      locale: localUS.default // changing the datepicker's language to english
    }
    this.optionUpdate.next(this.options)
  }

// to enable and disable

  isDisabled = false;

  toggleDisable() {
    this.formGroup.controls.date[this.isDisabled ? 'enable' : 'disable']();
    this.isDisabled = !this.isDisabled;
  }
<form [formGroup]="formGroup">
  <ngx-datetimePicker formControlName="date" [options]="options" [optionUpdate]="optionUpdate"> </ngx-datetimePicker>

  <h2>Change the formatv and langugae of the date picker</h2>

  <button (click)="changeToFrench()">French (France)</button>
  <button (click)="changeToEnglish()">English (USA)</button>

  <h2>Enable /disable</h2>

  <button (click)="toggleDisable()">{{ isDisabled ? "enable" : "disable" }}</button>
</form>

Theme customization

This examples uses SASS as style preprocessor.

.material {
  .calendar-container {
    background-color: #493c80;
    border: 1px solid #493c80;
  }
}

And in your component:

import { DatepickerOptions } from "@tchitos/datetime-picker";

options: DatepickerOptions = {
  calendarClass: "material"
};

Run Project

  1. Clone this repository.
git clone https://github.com/aminetchitooss/angular-datetime-picker
  1. Install dependencies
npm install
  1. Start the demo
npm start

License

MIT