Git Product home page Git Product logo

ngx-datetimepicker's Introduction

Note

This project is no longer actively maintained.

We want to thank everyone for their contributions and hope we've helped you in your coding journey.

ngx-datetime-picker

  • No jQuery or other external dependencies
  • Three separate components for Date Time, Date, and Time picker
  • When being used on a mobile or touch devices, it falls back to HTML5 inputs of date, datetime-local, and time

npm npm

Demo

Live demo can be found at https://renovosolutions.github.io/ngx-datetimepicker/.

Date time picker that falls back to native HTML5 components on mobile

DateTime formats

Date formats are called at datePicker.component.ts - functions formattedDate() and mobileFormattedDate().

Time formats are called at timePicker.component.ts - functions formattedTime() and mobileFormattedTime().

DateTime formats are called at dateTimePicker.component.ts - functions formattedDate() and mobileFormattedDate().

Change these calls to a different format to get different results. All formats are defined in date.service.ts.

Usage

import { DateTimePickerModule} from 'ngx-datetime-picker';

@NgModule({
  imports: [
    DateTimePickerModule
  ],
<ngx-datetime-picker [(selectedDateTime)]="dateTimeExample"></ngx-datetime-picker>

<ngx-date-picker [(selectedDate)]="dateExample"></ngx-date-picker>

<ngx-time-picker [(selectedTime)]="timeExample"></ngx-time-picker>

Additional options for each picker:

  • [disableButton]="false" (default)
  • [disableInput]="false" (default)
  • [disablePicker]="false" (default)
  • [doNotCloseOnDateSet]="false" (default)

Additional options for ngx-date-picker and ngx-datetime-picker:

  • [min]="null" (default)
  • [max]="null" (default)

Additional options for ngx-time-picker and ngx-datetime-picker:

  • [use24HourClock]="false" (default)

CSS

Compile ngx-datetime-picker.css from SCSS and copy into to your project.

If you are using angular-cli, the css can be added to your angular-cli.json:

"styles": [
  "../node_modules/ngx-datetime-picker/ngx-datetime-picker.css"
]

SCSS files available for quick customization. Override the defaults, compile, and include them in your project.

Development:

Work flow

  • Clone repository to your machine.

  • Run npm run setup to prepare the project.

  • Live edit mode with npm run serve.

  • Run tests with watcher with npm run test.

  • Run tests without a watcher with npm run test.once.

  • Prepare for distribution with npm run dist. (Note: you may need to also run tsc index.ts if you have updated the exported values)

  • Test a demo project using the exported ngModule with npm run demo.

  • Sass files are compiled locally using Koala.

  • Set Koala to watch date.component.scss and compile it to ngx-datetimepicker > src > assets as ngx-datetime-picker.css.

  • Optionally, you can use https://github.com/angular-buch/angular-cli-ghpages to publish the demo install to github pages. First run npm run demo, then switch into your demo directory with cd demo. From there, you can copy and paste the two commands to publish to github pages:

    ng build --prod --aot --base-href "https://renovosolutions.github.io/ngx-datetimepicker/"
    
    ngh --repo=https://github.com/renovosolutions/ngx-datetimepicker.git

    Note: this will publish to the gh-pages branch and you wil need to authenticate again.

Requirements

  • angular-cli 12.2.16 or higher, known issues with version 13
  • node 10 or higher

Contributors

JoshDSommer BrentWMiller benjamin-a-kuntz SFarageNIS Marco Mantovani Jojie Palahang Sam Graber alecrem jrquick17
Josh Sommer Brent Miller Benjamin Kuntz Steven Farage Marco Mantovani Jojie Palahang Sam Graber Alejandro Cremades Jeremy Quick
Personal

ngx-datetimepicker's People

Contributors

alecrem avatar benjamin-a-kuntz avatar brentwmiller avatar chaudhryatif avatar dependabot[bot] avatar ibedard16 avatar joshdsommer avatar jrquick17 avatar jtest15 avatar samgraber avatar sfaragenis avatar sslopek avatar theland avatar theoriginaljosh avatar totati avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ngx-datetimepicker's Issues

.invalid won't clear upon manual edit

If you manually remove the last letter (the 'm') making the string invalid, then the .invalid class appears on the div, as expected. However, picking a valid date/time with the mouse does not clear the .invalid class. You must manually edit the date, making it valid. Then onblur removes the .invalid class. That is the only way to clear the .invalid class. I believe this is because the newDatePicked function does not clear the this.invalid field.

Format Date

Could you tell me how to format show in input like "DD-MMM-YYYY"?

`npm test` is broken

Right now, the test script in package.json is npm test.

That means that, when I try to run tests, npm just runs the same command a few times until it gets tired. It fortunately doesn't do it forever.

I tried to run tests more directly with ng test, and that command was broken too. The tests need to be fixed.

Production build fails using ng build --prod

Compiles successfully when runs ng serve, but the build fails when using ng build --prod
Below are my dependencies

    "@angular/animations": "~7.1.0",
    "@angular/common": "~7.1.0",
    "@angular/compiler": "~7.1.0",
    "@angular/core": "~7.1.0",
    "@angular/forms": "~7.1.0",
    "@angular/platform-browser": "~7.1.0",
    "@angular/platform-browser-dynamic": "~7.1.0",
    "@angular/router": "^5.0.0",
    "@ng-idle/core": "^2.0.0-beta.15",
    "@ng-idle/keepalive": "^2.0.0-beta.15",
    "@okta/okta-signin-widget": "^2.21.0",
    "ag-grid-angular": "^21.2.2",
    "ag-grid-community": "^21.2.2",
    "ag-grid-enterprise": "^21.2.2",
    "angular-tree-component": "^8.4.0",
    "bootstrap": "4.2.1",
    "core-js": "^2.6.9",
    "file-saver": "^2.0.2",
    "lodash": "^4.17.15",
    "ngx-bootstrap": "^3.3.0",
    "ngx-datetime-picker": "^3.0.0",
    "ngx-order-pipe": "^2.0.3",
    "npm": "^6.11.2",
    "popper.js": "^1.14.7",
    "rxjs": "^6.5.2",
    "rxjs-compat": "^6.5.2",
    "sweetalert2": "^8.16.3",
    "tslib": "^1.10.0",
    "web-animations-js": "^2.3.2",
    "zone.js": "~0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.13.9",
    "@angular/cli": "~7.1.0",
    "@angular/compiler-cli": "~7.1.0",
    "@angular/language-service": "~7.1.0",
    "@types/file-saver": "^2.0.1",
    "@types/jasmine": "~2.8.8",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "~4.5.0",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~3.1.1",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "^2.0.6",
    "karma-jasmine": "~1.1.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.4.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.11.0",
    "typescript": "~3.1.6"
  }```

ERROR in ./node_modules/ngx-datetime-picker/fesm5/ngx-datetime-picker.js
Module build failed (from ./node_modules/@angular-devkit/build-optimizer/src/build-optimizer/webpack-loader.js):
TypeError: Cannot read property 'kind' of undefined
at isAngularDecoratorMetadataExpression (/node_modules/@angular-devkit/build-optimizer/src/transforms/scrub-file.js:265:35)
at checkNodeForDecorators (/node_modules/@angular-devkit/build-optimizer/src/transforms/scrub-file.js:77:21)
at visitNodes (/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:16144:30)
at Object.forEachChild (/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:16370:24)
at checkNodeForDecorators (/node_modules/@angular-devkit/build-optimizer/src/transforms/scrub-file.js:68:31)
at visitNode (/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:16135:24)
at Object.forEachChild (/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:16265:21)
at checkNodeForDecorators (/node_modules/@angular-devkit/build-optimizer/src/transforms/scrub-file.js:68:31)
at visitNode (/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:16135:24)
at Object.forEachChild (/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:16322:24)
at checkNodeForDecorators (/node_modules/@angular-devkit/build-optimizer/src/transforms/scrub-file.js:68:31)
at visitNode (/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:16135:24)
at Object.forEachChild (/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:16333:24)
at checkNodeForDecorators (/node_modules/@angular-devkit/build-optimizer/src/transforms/scrub-file.js:68:31)
at visitNode (/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:16135:24)
at Object.forEachChild (/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:16229:21)
at checkNodeForDecorators (/node_modules/@angular-devkit/build-optimizer/src/transforms/scrub-file.js:68:31)
at visitNodes (/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:16144:30)
at Object.forEachChild (/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:16379:24)
at checkNodeForDecorators (/node_modules/@angular-devkit/build-optimizer/src/transforms/scrub-file.js:68:31)
at visitNode (/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:16135:24)
at Object.forEachChild (/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:16377:21)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] buildProd: ng --prod build
npm ERR! Exit status 1
npm ERR!
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:

npm ERR! /.npm/_logs/2019-11-17T21_27_04_106Z-debug.log

Update Angular

Hello, may you please update the peer dependencies so that we do not get the warnings about that? Thanks, you've done a great job with this component 👍

Documentation

Please add some doc on inputs and outputs we can use

Usage

Hello,
How do i use this in our angular 2 project with webpack

Thanks

Template files not found

Hi,

I tried to use your datepicker in an Ionic v2 project, but sadly I couldn't get it to work. I installed it, included it in my app.module.ts and then tried to use the , just like in the demo. However, when I try to load the page, I get the following error:

Unhandled Promise rejection: Failed to load time.component.html
Zone: <root> ; Task: Promise.then ; Value: Failed to load time.component.html undefined
Error: Uncaught (in promise): Failed to load time.component.html
GET http://localhost:8100/date.component.html 404 (Not Found)
GET http://localhost:8100/datePicker.component.html 404 (Not Found)
GET http://localhost:8100/datetimepicker.component.html 404 (Not Found)
GET http://localhost:8100/timePicker.component.html 404 (Not Found)

Might that be because ionic v2 is still based on ng2?

Thanks for your help!

Import Error For Latest Version 2.3.0

Hi,

I tried importing latest version 2.3.0 but error below shows
error TS2305: Module '"../../../../node_modules/ngx-datetime-picker/ngx-datetime-picker"' has no exported member 'DateTimePickerModule'.

I also checked ngx-datetime-picker.d.ts file in node_modules and found it exports from main.d.ts which exports nothing.
export {}

When I revert back to version 2.1.3, this issue is gone.

Please take a look. Thanks.

Cannot make a 'prod' build

ERROR in node_modules/ngx-datetime-picker/dateTimePicker.component/dateTimePicker.component.html(4,16): Property 'style' does not exist on type 'DateTimePickerComponent'. Did you mean 's
tyles'?

Use command to reproduce this:
ng build --prod

Tested in:
Angular ^8.2.3

ngx-datetimepicker gets hidden under rows and cells

I am implementing ngx-datetime picker in a Grid cell. the calendar is getting hidden inside the cell.
In bootstrap we have something called container ='Body' to solve such problems.

What CSS settings we can change here to achieve the same.

image

datetime doesn't seem to save

I'm using a ngx-datetime-picker. If I select a date/time with the mouse, the input control is populated with the new date/time and the next time the picker opens, it shows the new date/time, as expected. However, if I manually edit the text input, the new date/time stays in the edit box, but the picker does not reflect the change. Not sure why.

My code:
<ngx-datetime-picker [(selectedDateTime)]="myDate"
(selectedDateTimeChange)="myChange($event)">

Cannot build with Angular Ivy

When building with Ivy enabled I get this error Error: Internal Error: Unexpected interpolation from this package.

Calendar Issue

Why All the Calendars are appended to the component rather attaching to the Body any specific Reason for this.

Angular 6.x compatibility

PR #52 upgraded the project to work with Angular 5, but peer and dev dependencies in package.json are still referring to 4.x.

ExpressionChangedAfterItHasBeenCheckedError

Whenever I access the dropdown timepicker I receive the following error:
TimePickerComponent.html:1 ERROR Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'selectedHour: undefined'. Current value: 'selectedHour: 0'.

I have tried using both ngModel and selectedTime. Can anyone provide some guidance?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.