datetime - Flutter - 用我想醒来的小时确定睡觉的时间
问题描述
我是 Dart 和 Flutter 的新手,正在寻求帮助。我正在尝试这样做:
- 用户在库比蒂诺日期选择器中选择一个小时和分钟(这是他想在早上醒来的时间)
-我想确定他需要入睡的确切时间才能有 7 小时的良好睡眠。
(此功能有效,但我不知道如何将分钟添加到小时,然后确定正确的计算)
void Bed(int Heure, int Minute) {
if (Heure - Cycle <= 0) {
result = Heure - Cycle + 24;
} else {
result = Heure - Cycle;
}
}
谢谢您的帮助 !
解决方案
我只会在几分钟内计算。所以拿你的 hours*60 ,你只用分钟计算,然后最后转换回小时。
double total = 140; //Your total time converted to minutes
double mins = total % 60; //your minutes
double hrs = (total - mins) / 60; // your hours
print(mins);
print(hrs);
推荐阅读
- mongodb - 使用 mongoose mongo 加入两个不同的集合(按 id)
- cassandra - 如何确定 Cassandra 节点是否已耗尽?
- ruby-on-rails - 如何在 Rails 中根据请求验证 activerecord 字段?
- dart - 无法在 url 启动器中使用 #(快速拨号)
- javascript - 带有可变 url 的 Window.open ---我尝试了又尝试了 - 请指出我正确的方向
- user-interface - Yocto 3.9.0 上的 ROS 支持
- android - 如何使用 jitpack 提供 AAR 文件
- regex - 为什么我的负面回顾在正则表达式中不起作用?
- javascript - 如何创建 react-reveal 主页文本动画
- java - java - 如何从java中的字符串中删除字符串数组中除元素之外的所有内容?