Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
chronoshift
Advanced tools
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']
var tz = Timezone.fromJS("America/Los_Angeles");
var hourStart = chronoshift.hour.floor(new Date("2012-11-04T00:30:00-07:00"), tz));
hourStart.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".
var Duration = chronoshift.Duration;
var tz = Timezone.fromJS("America/Los_Angeles");
p1w = Duration.formJS('P1W');
var weekStart;
weekStart = p1w.floor(new Date("2013-09-29T01:02:03.456-07:00"), tz)
weekStart.getTime() === new Date("2013-09-29T00:00:00.000-07:00").getTime()
weekStart = p1w.floor(new Date("2013-10-03T01:02:03.456-07:00"), tz)
weekStart.getTime() === new Date("2013-09-29T00:00:00.000-07:00").getTime()
A duration can also be constructed from two dates and a timezone:
new Duration(
new Date("2012-10-29T00:00:00-07:00")
new Date("2012-11-05T00:00:00-08:00")
tz
).toString() // => 'P7D'
new Duration(
new Date("2012-01-01T00:00:00-08:00")
new Date("2013-03-04T04:05:06-08:00")
tz
).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.
1.1.0
FAQs
A tiny library for shifting time with timezones
The npm package chronoshift receives a total of 1,128 weekly downloads. As such, chronoshift popularity was classified as popular.
We found that chronoshift demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
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.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.