# ng-timeparser

> [![npm version](https://badge.fury.io/js/ng-timeparser.svg)](https://badge.fury.io/js/ng-timeparser) [![Build Status](https://travis-ci.org/feeloor/ng-timeparser.svg?branch=master)](https://travis-ci.org/feeloor/ng-timeparser)

Latest version **1.0.2** (published 2018-08-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install ng-timeparser
pnpm add ng-timeparser
yarn add ng-timeparser
bun add ng-timeparser
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2018-08-04 |
| First published | 2018-06-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 229 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Felix Khoi |
| Maintainers | feeloor |
| Keywords | angular, timeparser, time, clock, @feeloor |

## Links

- npm: https://www.npmjs.com/package/ng-timeparser
- Repository: https://github.com/feeloor/ng-timeparser
- Homepage: https://github.com/feeloor/ng-timeparser#readme
- Issues: https://github.com/feeloor/ng-timeparser/issues
- npm.io page: https://npm.io/package/ng-timeparser

## Dependencies (1)

- [tslib](https://npm.io/package/tslib.md) ^1.7.1

## Alternatives

- [@js-joda/timezone](https://npm.io/package/@js-joda/timezone.md) — 383.4K weekly downloads
- [chartjs-adapter-moment](https://npm.io/package/chartjs-adapter-moment.md) — 210.8K weekly downloads
- [strftime](https://npm.io/package/strftime.md) — 171.2K weekly downloads
- [vue-flatpickr-component](https://npm.io/package/vue-flatpickr-component.md) — 115.8K weekly downloads
- [timepicker](https://npm.io/package/timepicker.md) — 51.0K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2018-08-04
- 1.0.1 — 2018-06-17
- 1.0.0 — 2018-06-17
- 0.0.0 — 2018-06-17

## README

# NgTimeparser

[![npm version](https://badge.fury.io/js/ng-timeparser.svg)](https://badge.fury.io/js/ng-timeparser) [![Build Status](https://travis-ci.org/feeloor/ng-timeparser.svg?branch=master)](https://travis-ci.org/feeloor/ng-timeparser)

NgTimeparser is a Angular 5 service that helps you parse any time from a input field to a correct time.
It can handle both 12/24 hour formats.

## Install

***Install from npm***
```
npm i ng-timeparser
```

***Include in NgModule***

```typescript
@NgModule({
  declarations: [
    ...
  ],
  imports: [
    ...
    TimeParserModule
  ]
```

## Usage

You can either use the service directly or use the directive on your input-field.

### By Directive

***12 hour format***
```html
<input type="text" [(ngModel)]="inputTime" timeParser />
```

***24 hour format***
```html
<input type="text" [(ngModel)]="inputTime" timeParser militaryTime='true' />
```

### By Service

***Include service to component***
```typescript
constructor(private timeParserService: TimeParserService) {}
```

***12 hour format***
```typescript  
this.time = this.timeParserService.parseTime(this.time, false);
```

***24 hour format***
```typescript  
this.time = this.timeParserService.parseTime(this.time, true);
```

## Development server

Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.

## Running unit tests

Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).

---
_Source: https://npm.io/package/ng-timeparser · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
