
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
month-utils
Advanced tools
This is a short collection of methods for working with months and timestamps.
This is not a formatting library. It helps switch between Date objects and timestamps for such needs as finding the first timestamp of the first day of a month when the some later day is known. It is just a few of these kinds of methods.
Since the small number of methods are common occurring requirements the module proves useful to have for a number of projects.
Since the number of methods is few, the module is very short and uses less than 8K of space uncompressed and 4K compressed by terser.
For use in node.js projects:
npm install i --save month-utils
In your node.js program you can access classes in the following manner:
const month_utils = require('month-utils')
A rollup.config.js file has been added to the package. The npm package should be released after running npm run build. (That is best effort.)
Builds that use rollup may simply include event-days in their devDependencies field within package.json. It may help to run a second npm install a such:
npm install i --save-dev month-utils
Example: This class is being used in a Svelte project. The module is included in an App.svelte file as follows:
import month_utils from 'month-utils'
prev_midnight(local_clock_date)next_midnight(local_clock_date) part_of_day(local_clock_date,partial)hours_of(lapse)calc_days(t_time)in_interval(instant,t_start,t_end)first_day_of_month(a_date)first_day_of_month_ts(timestamp)lower_month_bounday(timestamp)first_day_of_next_month(a_date)first_day_of_next_month_ts(timestamp)next_month_startfirst_day_of_relative_month(a_date,nth)first_day_of_relative_month_ts(timestamp,nth)same_day(t1,t2)day_is_clock_day(a_day,year,month,local_clock_date)day_is_before_clock_day(a_day,year,month,local_clock_date)day_is_after_clock_day(a_day,year,month,local_clock_date)Given a date object for a time on a pariticular day, returns the timestamp of the preceding midnight.
Given a date object for a time on a pariticular day, returns the timestamp of the midnight for the end of the day.
Given a date object for a time on a pariticular day, returns the timestamp equal to the partial mutiplied by the difference between the next midnight and the prev midnight added to the preceding midnight. That is, the timestamp of a fraction of the day.
Given a timestamp representing a duration, returns the number of hours.
Given a timestamp representing a duration, returns the number of days.
Given a timestamp representing an instant of time, a start time and an end time for an interval, returns true if the instant is in the interval.
Given a Date representation of a point in time, returns the timestamp of the midnight starting the first day of the month containing the point in time.
The same as first day of month but this takes a timestamp representation of the point in time.
Alias for first day of month ts.
Given a Date representation of a point in time, returns the timestamp of the midnight starting the first day of the next month not containing the point in time.
The same as first day of next month but this takes a timestamp representation of the point in time.
Alias for first day of next month ts.
Given a Date representation of a point in time, returns the timestamp of the midnight starting the first day of the nth (number) beyond the month containing the point in time.
The same as first day of relative month but this takes a timestamp representation of the point in time.
Returns true if the two timestamps have the same date.
(day, year month, Date) returns true if the day given is the same day as the Date's day.
(day, year month, Date) returns true if the day given is less than the day that is the Date's day where the time is taken from the midnight before the day.
(day, year month, Date) returns true if the day given is greater than the day that is the Date's day where the time is taken from the midnight ending the day.
FAQs
Time slot scheduling classes relative to months as storage units
We found that month-utils demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.