
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
sainsburys-date
Advanced tools
Basic functions to convert a Date object into Sainsbury's financial calendar components
Basic functions to convert a date object or string into Sainsbury's financial calendar components or vice-versa.
Run npm install sainsburys-date
to install the package into your application, then use import
(or require
) to bring it in.
import sainsburysDate from 'sainsburys-date'
fromDate(date | dateStr)
This converts a Date
object or yyyy-mm-dd
string into it's Sainsbury's calendar parts.
const date = sainsburysDate.fromDate('2015-10-05')
console.log(date.year) // 2015
console.log(date.quarter) // 3
console.log(date.period) // 8
console.log(date.week) // 2
toDate({ year, quarter, period, week, day })
This calculates the date represented by the passed Sainsbury's calendar parts. Dates are calculated starting from the year option
, offset by the quarter
, period
, week
and day
optional parts (summated in their respective order).
const a = sainsburysDate.toDate({ year: 2015, period: 8, week: 2 })
const b = sainsburysDate.toDate({ year: 2015, week: 30 })
const c = sainsburysDate.toDate({ year: 2017, day: 15 })
const d = sainsburysDate.toDate({ year: 2017, quarter: 4 })
console.log(a) // new Date('2015-10-04')
console.log(b) // new Date('2015-10-04')
console.log(c) // new Date('2017-03-26')
console.log(d) // new Date('2017-12-17')
At some point Sainsbury's will need to introduce a "leap" week or period otherwise the start of the financial year will fall into the previous year!
However, a decision on how to introduce this hasn't been made yet and this won't be a problem until Sun Dec 31 2073
(which will otherwise be the Q1 for 2074)
FAQs
Basic functions to convert a Date object into Sainsbury's financial calendar components
The npm package sainsburys-date receives a total of 756 weekly downloads. As such, sainsburys-date popularity was classified as not popular.
We found that sainsburys-date demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 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.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.