1.5.7 • Published 6 months ago

timestamp-date v1.5.7

Weekly downloads
51
License
ISC
Repository
github
Last release
6 months ago

TimestampDate

TimestampDate is a simple date-timestamp tool provided by Anchor Solutions to convert dates, string dates and timestamps in JavaScript objects to/from JS Date object. It can recursively parse the object document tree presented to locate each timestamp or date values and then convert to the expected type.

Installation

Install timestamp-date via npm by running the following command:

npm install timestamp-date --save

Usage

Create and instance and call available methods from the instance created.

import { TimestampDate } from 'timestamp-date';

const timestampDate = new TimestampDate();

Use TimestampDate utilities functions

// 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
getServerTimestampTimestampGets current timestamp value representative from firebase.
getServerDateDateGets current date value from firebase
timestampToDateTimestampDateConverts timestamp object to date object
dateToTimestampDateTimestampConverts JS date object to timestamp
parseTimestampToDate<T, R>Recursively iterates through properties of a JS object and converts all occurences of timestamp to normal JS Date
parseDateToTimestamp<T, R>Recursively iterates through properties of a JS object and converts all occurences of JS Date to timestamp object
parseStringToDate<T, R>Recursively iterates through properties of a JS object and converts all occurences of valid date string values to JavaScript Date objects
parseDateToString<T, R>Recursively iterates through properties of a JS object and converts all occurences of JS Date to date strings types.

Further Reading

Have a look at other packages by Anchor Solutions:

1.5.5

6 months ago

1.5.4

6 months ago

1.5.3

6 months ago

1.5.2

6 months ago

1.5.7

6 months ago

1.5.6

6 months ago

1.1.9

8 months ago

1.5.1

8 months ago

1.5.0

8 months ago

1.3.0

2 years ago

1.2.5

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago