[英]Find overlapping date ranges in IndexedDB
I would like to find which date ranges overlaps a period in IndexedDB. 我想找到哪个日期范围与IndexedDB中的某个时期重叠。
My idea was to store my events in a database, then make a query to get the events which overlap the period range. 我的想法是将事件存储在数据库中,然后进行查询以获取与周期范围重叠的事件。
Something like the following query (sorry, I don't really remember how to write SQL): 类似于以下查询(很抱歉,我真的不记得如何编写SQL):
SELECT * FROM events
WHERE (startTime BETWEEN periodStart AND periodEnd)
OR
(periodStart > startDate AND periodStart < endTime)
Unfortunately, the only possibility that I found with IndexedDB is to test if a date overlap a range. 不幸的是,我发现IndexedDB的唯一可能性是测试日期是否与范围重叠。
For your informations, my events look like the following object: 供您参考,我的事件类似于以下对象:
[{
title: 'foo',
start: '2013-06-30',
end: '2013-07-03'
},
{
title: 'bar',
start: '2013-07-04',
end: '2013-07-11'
}]
And a period is like: 一段是这样的:
var periodStart = '2013-06-30';
var periodEnd = '2013-07-05';
为什么不只使用时间戳的数值?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.