Socket
Socket
Sign inDemoInstall

ngx-timestamp-date

Package Overview
Dependencies
1
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    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


Version published
Weekly downloads
6
increased by100%
Maintainers
1
Install size
100 kB
Created
Weekly downloads
 

Readme

Source

NgxTimestampDate

NgxTimestampDate is a simple @angular/fire tool provided by Anchor Solutions 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).

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:

@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 NameParamsReturn typeDescription
timestampToDateTimestampDateConverts timestamp object to date object
dateToTimestampDateTimestampConverts JS date object to timestamp
parseTimestampToDateRecursively 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:

Keywords

FAQs

Last updated on 13 Apr 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc