Nonchalantly Performs Magic

    This package has been deprecated

    Author message:

    Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

    ngx-timestamp-date
    TypeScript icon, indicating that this package has built-in type declarations

    0.0.3 • Public • Published

    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 Name Params Return type Description
    timestampToDate Timestamp Date Converts timestamp object to date object
    dateToTimestamp Date Timestamp Converts JS date object to timestamp
    parseTimestampToDate 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:

    Install

    npm i ngx-timestamp-date

    DownloadsWeekly Downloads

    0

    Version

    0.0.3

    License

    none

    Unpacked Size

    68.7 kB

    Total Files

    26

    Last publish

    Collaborators

    • tumba