
使用 Logseq 编写模板的时候,发现获取日期的逻辑难以理解,我在 Mac 的系统设置中设定每周从周日开始,今天是 2023-09-11 ,那么本周应该是从 2023-09-10 到 2023-09-16 ,但查出来的日期感觉非常奇怪,有没有前端大佬可以解释一下原因
node Welcome to Node.js v18.17.1. Type ".help" for more information. > const chrOno= require('chrono-node'); undefined > chrono.parseDate('friday') 2023-09-08T04:00:00.000Z > chrono.parseDate('this friday') 2023-09-15T04:00:00.000Z > chrono.parseDate('thursday') 2023-09-14T04:00:00.000Z > chrono.parseDate('sunday') 2023-09-10T04:00:00.000Z > chrono.parseDate('this sunday') 2023-09-17T04:00:00.000Z > chrono.parseDate('today') 2023-09-11T09:14:35.989Z > 1 RRRoger 2023-09-11 17:30:18 +08:00 看起来返回的是当地时间的 12 点 取的是中间值 试试 chrono.parseDate('this friday at 0'); |
2 mdn 2023-09-11 17:31:42 +08:00 |
3 edward1987 2023-09-11 17:37:58 +08:00 这是这个模块的逻辑奇怪吧。 如果不需要用到这么复杂的语义,直接用 dayjs ,可以设置每周的开始是周几 |
4 dreasky 2023-09-12 09:04:58 +08:00 这模块的问题把 Nodejs: 这锅我不背 |