Skip to content

Commit

Permalink
🐛 fix: sql 的 strftime 没有返回当地的时间
Browse files Browse the repository at this point in the history
  • Loading branch information
frostime committed Nov 10, 2024
1 parent 4bfce7e commit 3ddbd16
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "siyuan-dailynote-today",
"version": "1.7.0",
"version": "1.7.1",
"description": "",
"main": ".src/index.js",
"keywords": [],
Expand Down
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"en_US": "Daily Note Today"
},
"url": "https://github.com/frostime/siyuan-dailynote-today",
"version": "1.7.0",
"version": "1.7.1",
"minAppVersion": "3.1.7",
"description": {
"zh_CN": "自动创建日记 + 快速打开日记 + 日程 TODO 管理 + 移动块功能",
Expand Down
9 changes: 5 additions & 4 deletions src/func/reserve/retrieve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @Author : Yp Z
* @Date : 2023-06-17 13:55:54
* @FilePath : /src/func/reserve/retrieve.ts
* @LastEditTime : 2024-09-13 11:48:53
* @LastEditTime : 2024-11-10 13:01:21
* @Description :
*/
import * as serverApi from '@/serverApi';
Expand Down Expand Up @@ -184,11 +184,12 @@ export function RetvFactory(type: RetvType, position: RetvPosition, resvBlockIds
export async function retrieveResvFromBlocks(time: 'today' | 'future' | 'datetime', ...datetimeArgs: string[]): Promise<Reservation[]> {
let cond = '';
if (time === 'today') {
cond = `A.value = strftime('%Y%m%d', datetime('now'))`;
cond = `A.value = strftime('%Y%m%d', datetime('now', 'localtime'))`;
} else if (time === 'future') {
cond = `A.value >= strftime('%Y%m%d', datetime('now'))`;
cond = `A.value >= strftime('%Y%m%d', datetime('now', 'localtime'))`;
} else if (time === 'datetime') {
cond = `A.value >= strftime('%Y%m%d', datetime('now', ${datetimeArgs.map((arg) => `'${arg}'`).join(',')}))`;
// 假设 datetimeArgs 包含时间偏移量,例如 '-7 days'
cond = `A.value >= strftime('%Y%m%d', datetime('now', 'localtime', ${datetimeArgs.map((arg) => `'${arg}'`).join(',')}))`;
}
let sql = `select B.id, B.content, A.value as date from blocks as B inner join attributes as A
on(A.block_id = B.id and A.name = 'custom-reservation' and ${cond}) order by A.value;`;
Expand Down

0 comments on commit 3ddbd16

Please sign in to comment.