【npm】一款时间日期工具库,你可以使用它来实现精美日历或欢迎页

时间转换工具

  • author: Vinca
  • mailbox: 237690966@qq.com
  • UpdateTime: 2024/6/13 15:29:18

安装

npm install v_datejs

引用

import v from "v_datejs";

使用

html:

<template><code>{{ v.tm() }}</code>
</template>

js:

<script>v.tm();</script>

调用

获取当前时间
v.ct();
2024/6/13 14:46:32
获取当前时间并补 0
v.ctz();
2024/06/13 14:46:32
获取当前时间-拼接时间
v.ctc();
2024-6-13 15:00:34
获取当前时间-拼接时间并补 0
v.ctcz();
2024-06-13 15:00:34
日期标识符转换
/** @param {String} date* @param {String} symbol* @example v.dic(date, symbol);*/
v.dic("2024-01-01", "-");
2024-01-01
时间戳转换成日期时间
/** @param {*} timestamp* @param {String} type* @param {Boolean} sup* @example v.tm(timestamp, type, sup);*/
v.tm();
v.tm(new Date(), "date");
v.tm(new Date(), "time");
v.tm(new Date(), "date", true);
v.tm(new Date(), "", true);
v.tm(1718163186898, "time");
v.tm("1718163186898", "time");
v.tm("1718163186898", "date", true);
2024/6/13 15:03:46
2024/6/13
15:03:46
2024/06/13
2024/06/13 15:03:46
15:03:46
15:03:46
2024/06/13
获取上一周日期
/** @param {String | undefined} date* @returns Array*/
v.lw("2024-6-13");
v.lw();
["2024/06/03","2024/06/04","2024/06/05","2024/06/06","2024/06/07","2024/06/08","2024/06/09"]
["2024/06/03","2024/06/04","2024/06/05","2024/06/06","2024/06/07","2024/06/08","2024/06/09"]
获取下一周日期
/** @param {String | undefined} date* @returns Array*/
v.nw("2024-6-13");
v.nw();
["2024/06/17","2024/06/18","2024/06/19","2024/06/20","2024/06/21","2024/06/22","2024/06/23"]
["2024/06/17","2024/06/18","2024/06/19","2024/06/20","2024/06/21","2024/06/22","2024/06/23"]
获取当前周
/** @param {*} date* @returns number*/
v.cw("2024-6-13");
v.cw();
24
获取今年的天数
/** @param {Number | String | undefined} year* @returns number*/
v.yd("2000");
v.yd(2023);
v.yd();
366
365
366
获取当前星期几
/** @param {*} date* @returns number*/
v.cdw();
v.cdw(new Date());
v.cdw("2024-6-1");
星期四
星期四
星期六
有趣的事情
/** @param {String | Number} year* @returns Array*/
v.funny(2019);
v.funny("2019");
["2019年新冠肺炎疫情爆发","时间:2019年底至2020年初","地点:全国各地","人物:患者、医护人员、政府官员","要素:传染病、防控、医疗资源","事情:新型冠状病毒引发的疫情在中国全国范围内迅速蔓延,造成大量感染和死亡病例。","结果:政府采取了一系列严厉的防控措施,包括封城、隔离、大规模检测等,最终有效控制了疫情的传播。"
]
获取当月的天
/** @param {String | Number | undefined} month* @returns Array*/
v.cmod();
v.cmod("5");
v.cmod(1);
 [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30][1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31][1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]
指定月份日历表
/** @param {String | Number} month* @returns Array*/
v.cmdw(6);
v.cmdw("6");
[{"day": 1,"active": false,"week": "星期六","month": 6,"month_abb": "Jun.","month_ch": "六月","month_en": "June","date": "2024-06-01"},{"day": 2,"active": false,"week": "星期日","month": 6,"month_abb": "Jun.","month_ch": "六月","month_en": "June","date": "2024-06-02"},{"day": 3,"active": false,"week": "星期一","month": 6,"month_abb": "Jun.","month_ch": "六月","month_en": "June","date": "2024-06-03"},{"day": 4,"active": false,"week": "星期二","month": 6,"month_abb": "Jun.","month_ch": "六月","month_en": "June","date": "2024-06-04"},{"day": 5,"active": false,"week": "星期三","month": 6,"month_abb": "Jun.","month_ch": "六月","month_en": "June","date": "2024-06-05"},{"day": 6,"active": false,"week": "星期四","month": 6,"month_abb": "Jun.","month_ch": "六月","month_en": "June","date": "2024-06-06"},{"day": 7,"active": false,"week": "星期五","month": 6,"month_abb": "Jun.","month_ch": "六月","month_en": "June","date": "2024-06-07"},{"day": 8,"active": false,"week": "星期六","month": 6,"month_abb": "Jun.","month_ch": "六月","month_en": "June","date": "2024-06-08"},{"day": 9,"active": false,"week": "星期日","month": 6,"month_abb": "Jun.","month_ch": "六月","month_en": "June","date": "2024-06-09"},{"day": 10,"active": false,"week": "星期一","month": 6,"month_abb": "Jun.","month_ch": "六月","month_en": "June","date": "2024-06-10"},{"day": 11,"active": false,"week": "星期二","month": 6,"month_abb": "Jun.","month_ch": "六月","month_en": "June","date": "2024-06-11"},{"day": 12,"active": false,"week": "星期三","month": 6,"month_abb": "Jun.","month_ch": "六月","month_en": "June","date": "2024-06-12"},{"day": 13,"active": true,"week": "星期四","month": 6,"month_abb": "Jun.","month_ch": "六月","month_en": "June","date": "2024-06-13"},{"day": 14,"active": false,"week": "星期五","month": 6,"month_abb": "Jun.","month_ch": "六月","month_en": "June","date": "2024-06-14"},{"day": 15,"active": false,"week": "星期六","month": 6,"month_abb": "Jun.","month_ch": "六月","month_en": "June","date": "2024-06-15"},{"day": 16,"active": false,"week": "星期日","month": 6,"month_abb": "Jun.","month_ch": "六月","month_en": "June","date": "2024-06-16"},{"day": 17,"active": false,"week": "星期一","month": 6,"month_abb": "Jun.","month_ch": "六月","month_en": "June","date": "2024-06-17"},{"day": 18,"active": false,"week": "星期二","month": 6,"month_abb": "Jun.","month_ch": "六月","month_en": "June","date": "2024-06-18"},{"day": 19,"active": false,"week": "星期三","month": 6,"month_abb": "Jun.","month_ch": "六月","month_en": "June","date": "2024-06-19"},{"day": 20,"active": false,"week": "星期四","month": 6,"month_abb": "Jun.","month_ch": "六月","month_en": "June","date": "2024-06-20"},{"day": 21,"active": false,"week": "星期五","month": 6,"month_abb": "Jun.","month_ch": "六月","month_en": "June","date": "2024-06-21"},{"day": 22,"active": false,"week": "星期六","month": 6,"month_abb": "Jun.","month_ch": "六月","month_en": "June","date": "2024-06-22"},{"day": 23,"active": false,"week": "星期日","month": 6,"month_abb": "Jun.","month_ch": "六月","month_en": "June","date": "2024-06-23"},{"day": 24,"active": false,"week": "星期一","month": 6,"month_abb": "Jun.","month_ch": "六月","month_en": "June","date": "2024-06-24"},{"day": 25,"active": false,"week": "星期二","month": 6,"month_abb": "Jun.","month_ch": "六月","month_en": "June","date": "2024-06-25"},{"day": 26,"active": false,"week": "星期三","month": 6,"month_abb": "Jun.","month_ch": "六月","month_en": "June","date": "2024-06-26"},{"day": 27,"active": false,"week": "星期四","month": 6,"month_abb": "Jun.","month_ch": "六月","month_en": "June","date": "2024-06-27"},{"day": 28,"active": false,"week": "星期五","month": 6,"month_abb": "Jun.","month_ch": "六月","month_en": "June","date": "2024-06-28"},{"day": 29,"active": false,"week": "星期六","month": 6,"month_abb": "Jun.","month_ch": "六月","month_en": "June","date": "2024-06-29"},{"day": 30,"active": false,"week": "星期日","month": 6,"month_abb": "Jun.","month_ch": "六月","month_en": "June","date": "2024-06-30"}
]
获取当前季度
/** @returns String*/
v.qua();
{"month": [ 4, 5, 6 ],"index": 1,"quarter": "第二季度"
}
距离新的一年剩余天数(包含当天)
/** @param {String | undefined} date* @returns Object*/
v.surp("2024-12-28");
v.surp();
{"currentDate": "2024/12/28","desc": "距离 2025 年还剩余 4 天","nextYear": 2025,"daysRemaining": 4
}
{"currentDate": "2024/06/13","desc": "距离 2025 年还剩余 202 天","nextYear": 2025,"daysRemaining": 202
}
本月剩余天数(包含当天)
/** @param {String | undefined} date* @returns Number*/
v.nm("2024-1-1");
v.nm("2024-6-30");
v.nm();
v.nm(Date.now());
v.nm(new Date());
31
1
18
18
18
近三天(包含当天)
/** @param {*} date* @param { Number, String } num* @returns Array*/
v.ntd();
v.ntd("2024-01-01");
v.ntd("2025-1-1");
v.ntd(new Date());
v.ntd(Date.now());
v.ntd(1718328252523);
v.ntd(new Date(), 7);
['2024/06/12', '2024/06/13', '2024/06/14']
['2023/12/30', '2023/12/31', '2024/01/01']
['2024/12/30', '2024/12/31', '2025/01/01']
['2024/06/12', '2024/06/13', '2024/06/14']
['2024/06/12', '2024/06/13', '2024/06/14']
['2024/06/12', '2024/06/13', '2024/06/14']
['2024/06/08', '2024/06/09', '2024/06/10', '2024/06/11', '2024/06/12', '2024/06/13', '2024/06/14']

链接: v_datejs

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/diannao/27298.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

go-zero整合Excelize并实现Excel导入导出

go-zero整合Excelize并实现Excel导入导出 本教程基于go-zero微服务入门教程&#xff0c;项目工程结构同上一个教程。 本教程主要实现go-zero框架整合Excelize&#xff0c;并暴露接口实现Excel模板下载、Excel导入、Excel导出。 go-zero微服务入门教程&#xff1a;https://blo…

Mysql学习(九)——存储引擎

提示&#xff1a;文章写完后&#xff0c;目录可以自动生成&#xff0c;如何生成可参考右边的帮助文档 文章目录 七、存储引擎7.1 MySQL体系结构7.2 存储引擎简介7.3 存储引擎特点7.4 存储引擎选择7.5 总结 七、存储引擎 7.1 MySQL体系结构 连接层&#xff1a;最上层是一些客户…

Web前端大结局:揭秘四重境界、五大法则、六大技巧与七大未来趋势

Web前端大结局&#xff1a;揭秘四重境界、五大法则、六大技巧与七大未来趋势 在浩瀚无垠的互联网世界中&#xff0c;Web前端技术以其独特的魅力&#xff0c;吸引着无数开发者投身其中。今天&#xff0c;我们将一起揭开Web前端的大结局&#xff0c;深入探讨其四重境界、五大法则…

自然语言处理领域的重大挑战:解码器 Transformer 的局限性

每周跟踪AI热点新闻动向和震撼发展 想要探索生成式人工智能的前沿进展吗&#xff1f;订阅我们的简报&#xff0c;深入解析最新的技术突破、实际应用案例和未来的趋势。与全球数同行一同&#xff0c;从行业内部的深度分析和实用指南中受益。不要错过这个机会&#xff0c;成为AI领…

MFC四种方法编写多线程

本文以四个demo为例&#xff0c;对MFC的多线程进行学习。学习的过程中写了四个demo&#xff0c;将其做成笔记&#xff0c;发布在csdn上面。 mfc多线程demo1 volatile BOOL m_bRun; CEdit* edit; void ThreadFunc(){CTime time;CString strTime;m_bRun true;while(m_bRun){ti…

聚焦赛宁网安竞赛平台+赛事服务,引领网络安全竞赛新潮流

第八届XCTF总决赛将在2024年6月22日于中国成都震撼开启&#xff0c;本届总决赛分为个人Live Solo和团队KOH巅峰对决两个赛道&#xff0c;从个人和团队多角度全方位考察参赛人员的竞技水平。 巅峰对决 智慧的火花在此碰撞 个人Live Solo赛制 Live Solo赛分为晋级赛和Solo赛。…

贝壳APP渗透测试WP

前期配置 环境说明 使用PIXEL 4手机&#xff0c;为Android 12系统 APP名为贝壳找房&#xff0c;包名com.lianjia.beike&#xff0c;版本号3.01.10&#xff0c;截至2024/05/07为最新版&#xff0c;小米应用市场下载 绕过反Frida机制 可以参考往期推送&#xff0c;《绕过最新…

2分钟用手机开发一个ChatBot

前言&#xff1a; 在上一期&#xff0c;我们测评了CodeFlying&#xff0c;用它开发出了一个复杂推文管理系统&#xff0c;然后体验了一下它的热门应用&#xff1a;AI智能机器人。今天咱就继续用CodeFlying来开发一个属于我们自己的聊天机器人。 老规矩&#xff0c;我们先在手机…

.pth文件是可以打开的吗?和.py文件是一样的吗?

#1 .pth文件是可以打开的吗&#xff1f;和.py文件是一样的吗&#xff1f; .pth文件&#xff08;通常是由PyTorch保存的模型权重文件&#xff09;和.py文件是完全不同的类型&#xff1a; pth文件&#xff1a;是二进制文件&#xff0c;保存了训练过程中模型的参数状态。这些文件…

【qt】平面CAD(计算机辅助设计 )项目 上

CAD 一.前言二.界面设计三.提升类四.接受槽函数五.实现图形action1.矩形2.椭圆3.圆形4.三角形5.梯形6.直线7.文本 六.总结 一.前言 用我们上节课刚刚学过的GraphicsView架构来绘制一个可以交互的CAD项目! 效果图: 二.界面设计 添加2个工具栏 需要蔬菜的dd我! 添加action: …

遗传算法求解车间调度问题(附python代码)

背景介绍 车间调度问题&#xff08;Job Shop Scheduling Problem, JSSP&#xff09;是一类经典的组合优化问题&#xff0c;它在制造业和生产管理中有着广泛的应用。JSSP 的目标是对车间中的一系列作业进行排程&#xff0c;以使得作业在不同机器上的加工顺序是最优的&#xff0…

万相台的功能是什么?如何使用万相台?

1.特点&#xff1a; 万相台是一个智能渠道&#xff0c;可控性弱&#xff0c;高转化&#xff0c;人群&关键词是黑盒&#xff1b; 2.场景多&#xff1a; 有拉新快、活动加速、上新快、货品加速、活动加速、多目标直投、全站推等&#xff1b; 3.扣费逻辑&#xff1a;cpc付…

Html_Css问答集(7)

46、在vscode&#xff0c;html与head和body在同一个垂直线上&#xff0c;它们并不是兄弟元素&#xff0c;为什么&#xff1f; 在 Code&#xff08;Visual Studio Code&#xff09;或其他代码编辑器中&#xff0c;HTML文档的格式和缩进方式可以帮助开发者更清晰地组织和理解代码…

Sm4【国密4加密解密】

当我们开发金融、国企、政府信息系统时&#xff0c;不仅要符合网络安全的等保二级、等保三级&#xff0c;还要求符合国密的安全要求&#xff0c;等保测评已经实行很久了&#xff0c;而国密测评近两年才刚开始。那什么是密码/国密&#xff1f;什么是密评&#xff1f;本文就关于密…

Linux:线程概念 线程控制

Linux&#xff1a;线程概念 & 线程控制 线程概念轻量级进程 LWP页表 线程控制POSIX 线程库 - ptherad线程创建pthread_createpthread_self 线程退出pthread_exitpthread_cancelpthread_joinpthread_detach 线程架构线程与地址空间线程与pthread动态库 线程的优缺点 线程概念…

机器学习与数据挖掘知识点总结(二)分类算法

目录 1、什么是数据挖掘 2、为什么要有数据挖掘 3、数据挖掘用在分类任务中的算法 朴素贝叶斯算法 svm支持向量机算法 PCA主成分分析算法 k-means算法 决策树 1、什么是数据挖掘 数据挖掘是从大量数据中发现隐藏在其中的模式、关系和规律的过程。它利用统计学、机器学…

关于数据库存储【\】转义字符反斜杠丢失的问题

背景 开始的时候&#xff0c;发现一个很奇怪的现象 富文本编辑器&#xff0c;前端存储带有"的内容&#xff0c;回显的时候解析就会出问题 后来发现&#xff0c;其实是只要是需要带有\进行转义的内容就会有问题 排查 从前端提交数据&#xff0c;后端获取数据&#xff…

CAPL如何在底层模拟TCP Client端建立TCP连接

TCP连接的三次握手过程中,Client端需要做的事情是:发起连接请求,接收Server端的连接请求并确认。 如果Client端不使用TCP/IP协议栈和Socket接口函数完成连接,而是通过组装以太网报文完成连接,需要注意: Client不使用TCP/IP协议栈,所以不应该配置TCP/IP协议栈。否则收到…

TCP协议参数设置说明

ip route下的tcp参数设置 能设置的参数不止这些&#xff0c;只列出了我们关心的 rto_min 通过路由表覆盖全局rto_min&#xff0c;最好是对端配合设置quickack 避坑&#xff1a;这玩意是用jiffies为单位记录的&#xff0c;jiffies的单位是4ms&#xff0c;配10ms的话生效的时候…

14.shell awk数组

awk数组 awk数组awk数组示例Nginx日志分析 awk数组 1.什么是awk数组 数组其实也算是变量,传统的变量只能存储一个值,但数组可以存储多个值 2.awk数组应用场景 通常用来统计、比如:统计网站访问TOP10、网站url访问TOP10等等 3.awk数组统计技巧 1.在awk中,使用数组时,不仅可以…