MCPcopy Create free account
hub / github.com/experdot/pointer / isInTimeRange

Function isInTimeRange

src/renderer/src/utils/globalSearchUtils.ts:72–95  ·  view source on GitHub ↗

* 检查消息是否在时间范围内

(createdAt: number, timeRange: GlobalSearchOptions['timeRange'])

Source from the content-addressed store, hash-verified

70 * 检查消息是否在时间范围内
71 */
72function isInTimeRange(createdAt: number, timeRange: GlobalSearchOptions['timeRange']): boolean {
73 if (timeRange === 'all') return true
74
75 const now = Date.now()
76 const messageTime = createdAt
77
78 switch (timeRange) {
79 case 'today': {
80 const todayStart = new Date()
81 todayStart.setHours(0, 0, 0, 0)
82 return messageTime >= todayStart.getTime()
83 }
84 case 'week': {
85 const weekAgo = now - 7 * 24 * 60 * 60 * 1000
86 return messageTime >= weekAgo
87 }
88 case 'month': {
89 const monthAgo = now - 30 * 24 * 60 * 60 * 1000
90 return messageTime >= monthAgo
91 }
92 default:
93 return true
94 }
95}
96
97/**
98 * 提取匹配文本的上下文片段

Callers 1

searchInMessagesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected