# ngx-timestamp-date

> NgxTimestampDate is a simple @angular/fire tool provided by [Anchor Solutions](https://www.anchorsolutions.nl) to convert timestamps in retrieved documents from firestore database back to JS Date object. It recursively parse the object document presented

Latest version **0.0.3** (published 2020-04-13) · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install ngx-timestamp-date
pnpm add ngx-timestamp-date
yarn add ngx-timestamp-date
bun add ngx-timestamp-date
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2020-04-13 |
| First published | 2020-02-26 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 67.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | tumba |
| Keywords | timestamp, firebase, angularfire, javascript date |

## Links

- npm: https://www.npmjs.com/package/ngx-timestamp-date
- npm.io page: https://npm.io/package/ngx-timestamp-date

## Dependencies (1)

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

## 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

- 0.0.3 (latest) — 2020-04-13
- 0.0.2 — 2020-02-26
- 0.0.1 — 2020-02-26

## README

# NgxTimestampDate

NgxTimestampDate is a simple @angular/fire tool provided by [Anchor Solutions](https://www.anchorsolutions.nl) to convert timestamps in retrieved documents from firestore database back to JS Date object. It recursively parse the object document presented to located timestamp values and then convert them to JS Date normally.

## Installation
Install ngx-timestamp-date via npm by running the following command: 
> `npm install ngx-timestamp-date --save`

## Usage
Register the `NgxTimestampDateModule` in your app module (or any other module you want to use it).

 ```typescript
import { NgxTimestampDateModule } from 'ngx-timestamp-date';

@NgModule({
  declarations: [],
  imports: [
    ...,
    NgxTimestampDateModule
  ],
  providers: [],
  bootstrap: []
})
export class AppModule {}
 ``` 

### Use `NgxTimestampDateService` service from anywhere in your app like below:
```typescript
@Injectable({
  providedIn: 'root'
})
export class MyService {
  constructor(private timestampService: NgxTimestampDateService) {
      // converts all timestamp in doc to js date
      const doc = {
          a: {},
          b: {
              c: [
                  d: <Timestamp>
              ],
              e: <Timestamp>
          }
      };

      const updated = this.timestampService.parseTimestampToDate(doc);

      console.log(doc, updated);
  }
}
```

### Methods
| Method Name | Params  | Return type | Description                                        |
|-------------|---------|-------------|----------------------------------------------------|
| timestampToDate        | Timestamp  | Date           | Converts timestamp object to date object |
| dateToTimestamp        | Date  | Timestamp        | Converts JS date object to timestamp                      |
| parseTimestampToDate<T>    | <T> | <T>       | Recursively iterates through properties of a JS object and convert all occurences of timestamp to normal JS Date        |

### Further Reading
Have a look at other packages by [Anchor Solutions](https://www.anchorsolutions.nl):
- [NgxPincode](https://www.npmjs.com/package/ngx-pincode)
- [translator-client-module](https://www.npmjs.com/package/translator-client-module)
- [MatModal](https://www.npmjs.com/package/mat-modal)

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