Flutter / Dart-确定从您要醒来的时间开始的睡眠周期计算

问题描述 投票:0回答:1

我希望获得一些帮助来完成此计算,我在数学上还不够好,无法找到正确的答案!此示例睡眠周期与您要唤醒的小时和分钟作为输入。

我在这里有个大问题:

-当我通过0h00时,我的计算结果为负,因此我加了+24,但我认为这不是正确的方法

-我想确定newhrs2和newhrs3

如果有人可以帮助我,我将很高兴!

Sleep cycle

  static double Cycle = 360;
  static double result;
  static int total;
  static int mins;
  static double hrs;

  static double newmin;
  static double newhrs;
  static double newhrs2; //this is another cycle : it's newhrs -= 1 hour
  static double newhrs3; //this is another cycle : it's newhrs -= 3 hour

  void Calcul(int Hour, int Minutes) {
    total = (Hour * 60) + Minutes; //total time in minutes

    mins = total % 60; //your minutes

    hrs = (total - mins) / 60; // your hours

    if (total <= 360) {
      result = total - Cycle;
      newmin = result % 60.0;
      newhrs = (result - newmin) / 60 + 24;

    } else {
      result = total - Cycle;
      newmin = result % 60.0;
      print(newmin);
      newhrs = (result - newmin) / 60;
    }

  }
flutter dart sleep cycle
1个回答
0
投票

嗨,有人可以帮助我吗?我无法弄清楚……谢谢!

© www.soinside.com 2019 - 2024. All rights reserved.