Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
timespan-js
Advanced tools
#timespanjs ##简介 实现日期差值的人性化显示的javascript库。比如,可以显示成:2年2个月2小时4分钟23秒。同时支持国际化,可扩展。已经支持的语言:
###如何使用
####浏览器下的引用
<script src="timespan.js"></script>
<script>
var ts=new Timespan(85,'m');
</script>
####requirejs下的引用
require.config({
paths: {
"timespanjs": "path/to/timespan",
}
});
define(["timespanjs"], function (Timespan) {
var ts=new Timespan(85,'m');
});
####node.js下的引用
####调用示例:
//该值表示为:3小时4分钟25秒30毫秒
var msvalue = 30 + 1000 * 25 + 1000 * 60 * 4 + 1000 * 60 * 60 * 3;
var ts = new Timespan(msvalue, 'ms');
console.log(ts.humanize());//输出为:3小时4分钟25秒30毫秒
//通过fromDates方法构造
var dt=new Date(2014,7,1);
var dt1=new Date(2014,8,1,10,12,15,234);
var ts = Timespan.fromDates(dt, dt1);
console.log(ts.humanize());
//输出:1个月1天10小时12分钟15秒,234毫秒未输出,因为baseUnit参数默认是:'s'
Timespan.lang('en');
console.log(ts.humanize());
//输出:1 month,1 day,10 hours,12 minutes,15 seconds
##API说明
见api说明。
##测试用例
见https://github.com/houyhea/timespanjs/blob/master/test/testTimespan.html。请获取并运行即可。
##浏览器兼容性
兼容IE8+,chrome,firefox。
##依赖
不需要依赖其他库。
##协议
采用MIT 许可协议。
##帮助
支付宝赞助(houyhea):
FAQs
A javascript libaray witch can support humanized dispay of the timespan.
The npm package timespan-js receives a total of 1 weekly downloads. As such, timespan-js popularity was classified as not popular.
We found that timespan-js 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.