Gathering detailed insights and metrics for chronoshift
Gathering detailed insights and metrics for chronoshift
Gathering detailed insights and metrics for chronoshift
Gathering detailed insights and metrics for chronoshift
npm install chronoshift
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
9 Stars
177 Commits
4 Forks
51 Watching
6 Branches
14 Contributors
Updated on 27 Nov 2024
TypeScript (99.04%)
JavaScript (0.96%)
Cumulative downloads
Total Downloads
Last day
18.6%
707
Compared to previous day
Last week
36.7%
4,340
Compared to previous week
Last month
-38.4%
17,336
Compared to previous month
Last year
257.2%
273,030
Compared to previous year
3
18
Chronoshift is a library to manipulate time with timezones
In node simply run: npm install chronoshift
In the browser you should use the browserified package/chronoshift.js
Chronoshift can be used in two ways:
Use chronoshift[period][fn](date, timezone, moveAmount)
where
period
is one of ['year', 'month', 'day', 'hour', 'minute', 'second', 'millisecond']
fn
is one of ['floor, ceil, move']
1var tz = Timezone.fromJS("America/Los_Angeles"); 2 3var hourStart = chronoshift.hour.floor(new Date("2012-11-04T00:30:00-07:00"), tz)); 4 5hourStart.getTime() === new Date("2012-11-04T00:00:00-07:00").getTime()
Construct a new duration with a ISO Duration string. Then you can call floor
, ceil
and move
on it.
Note that floor
and ceil
only work for 'simple' durations like "P1x" and "PT1x".
1var Duration = chronoshift.Duration; 2var tz = Timezone.fromJS("America/Los_Angeles"); 3 4p1w = Duration.formJS('P1W'); 5 6var weekStart; 7 8weekStart = p1w.floor(new Date("2013-09-29T01:02:03.456-07:00"), tz) 9weekStart.getTime() === new Date("2013-09-29T00:00:00.000-07:00").getTime() 10 11weekStart = p1w.floor(new Date("2013-10-03T01:02:03.456-07:00"), tz) 12weekStart.getTime() === new Date("2013-09-29T00:00:00.000-07:00").getTime()
A duration can also be constructed from two dates and a timezone:
1new Duration( 2 new Date("2012-10-29T00:00:00-07:00") 3 new Date("2012-11-05T00:00:00-08:00") 4 tz 5).toString() // => 'P7D' 6 7new Duration( 8 new Date("2012-01-01T00:00:00-08:00") 9 new Date("2013-03-04T04:05:06-08:00") 10 tz 11).toString() // => 'P1Y2M3DT4H5M6S'
Useful!
Clone the repository :
$ git clone https://github.com/implyio/chronoshift.git
Install the dependencies :
$ npm install
Watch :
$ npm run watch
Please file bugs and feature requests by opening and issue on GitHub and direct all questions to our user groups.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
12 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10
Reason
license file detected
Details
Reason
Found 4/17 approved changesets -- score normalized to 2
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
24 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More