Javascript 相互减去时间跨度
假设我有一个时间跨度 {"start_time":"8:30", "end_time":"18:00"}
我想减去其他时间跨度,例如 {"start_time": "12:30", "end_time":"14:00"}
并得到结果:[{"start_time":"8:30", "end_time":"12:30"},{"start_time":"14:00", "end_time":"18:00"}]
编辑:接下来我还需要减去其他时间跨度,例如 [{"start_time":"8:30", "end_time":"12:30"},{"start_time":"14:00", "end_time":"18:00"}] -
{"start_time":"16:30", "end_time":"17:00"}
这应该给我[{"start_time":"8:30", "end_time":"12:30"},{"start_time":"14:00", "end_time":"16:30"},{" start_time":"17:00", "end_time":"18:00"}]
我想知道最好的逻辑方法是什么。
谢谢
Suppose I have a time span {"start_time":"8:30", "end_time":"18:00"}
I want to subtract other time span like {"start_time":"12:30", "end_time":"14:00"}
and get a result of:[{"start_time":"8:30", "end_time":"12:30"},{"start_time":"14:00", "end_time":"18:00"}]
EDIT: I will also require to subtract other time spans next e.g[{"start_time":"8:30", "end_time":"12:30"},{"start_time":"14:00", "end_time":"18:00"}]
- {"start_time":"16:30", "end_time":"17:00"}
which should give me [{"start_time":"8:30", "end_time":"12:30"},{"start_time":"14:00", "end_time":"16:30"},{"start_time":"17:00", "end_time":"18:00"}]
I am wondering what is the best logical way to do it.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)