- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
使用 Moment.js,我试图检测商店开门和关门时间,但无论我如何研究文档和交换函数,我都会从 isBefore()< 得到
& false
响应isAfter()
m.opening=[
moment('11:30', "HH:MM"),
moment('01:30', "HH:MM") //1:30AM the next day
];
console.log(m.opening[1].isBefore(moment('07:00', "HH:MM"))); //always false no matter if I use isBefore() or isAfter()
if(m.opening[1].isBefore(moment('7:00', "HH:MM")))
m.opening[1].add(1,'day'); //If closing time is before 7AM add a day
m.range = m.moment.range(m.opening);
预先感谢您的帮助
最佳答案
您的值(value)观并未被设定为您认为的那样。
我添加了健全性检查,发现 m.opening
是一个具有两个空值的数组。
这让我阅读了文档,并且您传递了错误的字符串来解析时间。您想要的字符串是 HH:mm
,而不是 HH:MM
。
我在下面包含了一个片段,其中包含您的代码和工作示例。
仔细检查值是否符合您的预期应该始终是第一个调试步骤之一。
var m = {};
m.opening=[
moment('11:30', "HH:MM"),
moment('01:30', "HH:MM") //1:30AM the next day
];
console.log(m);
console.log(m.opening[1].isBefore(moment('07:00', "HH:MM"))); //always false no matter if I use isBefore() or isAfter()
//////////////
m.opening=[
moment('11:30', "HH:mm"),
moment('01:30', "HH:mm") //1:30AM the next day
];
console.log(m);
console.log(m.opening[1].isBefore(moment('07:00', "HH:mm"))); // Now returns true.
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.13.0/moment.min.js"></script>
关于javascript - Moment.js : Workout the store opening and closing hours,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37797137/
我创建了一个 Ruby on Rails 应用程序,用户可以在其中记录和分享他们的锻炼。我想知道如何允许用户“克隆”可以这么说的锻炼,从而节省复制和粘贴或自己输入锻炼所需的时间。 我的想法是,当当前用
我正在开发一个应用程序,其中使用了 HealthKit 并创建了 HKWorkout session 并将其添加到 HealthKit 商店。 现在,当我在 Watch 上使用 Apple 的原生锻炼
我可以开始和停止 HealthKit 锻炼类(class)。但是,当我在第一次锻炼停止后尝试开始第二次锻炼时,出现错误: "workOutSession Error : Stopped workout
使用 Moment.js,我试图检测商店开门和关门时间,但无论我如何研究文档和交换函数,我都会从 isBefore() 关于javascript - Moment.js : Workout the s
使用 HealthKit,我正在保存以下数据: 锻炼 活力 距离 我正在使用以下代码删除锻炼: self.healthStore?.delete(workout, withCompletion: {
我们能否在 SIRI 窗口中显示锻炼域的响应,就像我们显示消息、支付、骑行域一样? 最佳答案 目前,没有。看着 official documentation INStartWorkoutIntentR
我一段时间以来一直在尝试找出此错误的原因..当我查看 HealthKit documentation 时对于 HKError,我没有看到任何“锻炼当前错误”的列表,但是 case errorInval
所以我正在构建一个小型锻炼日志网络应用程序。截至目前,它应该做的就是拉出锻炼并显示锻炼名称。但thymeleaf似乎不知道exerciseName是什么。我的数据库中确实有一个带有锻炼名称的锻炼,但似
实际上,我在我的应用程序中使用 Siri 和锻炼域。据我所知,如果锻炼域没有“开始”、“结束”、“暂停”、“恢复”、“取消”和“锻炼”关键字,Siri 并不总是有效。 例如:- 如果我发出像 “使用
我是一名优秀的程序员,十分优秀!