examples/time/time_operations.ck
raw| 1 | // ... |
| 2 | |
| 3 | // store the current time |
| 4 | now => time t1; |
| 5 | |
| 6 | //value to duration |
| 7 | 0.5::second => dur d; |
| 8 | <<<"one">>>; |
| 9 | //now waits for that duration |
| 10 | d => now; |
| 11 | <<<"two">>>; |
| 12 | |
| 13 | //define new duration |
| 14 | d * 4.0 => dur four_d; |
| 15 | |
| 16 | //wait again. |
| 17 | four_d => now; |
| 18 | <<<"three">>>; |
| 19 | |
| 20 | now => time t2; |
| 21 | |
| 22 | t2 - t1 => dur span; |
| 23 | <<<"total">>>; |
| 24 | <<<span>>>; |
| 25 | <<<"relative">>>; |
| 26 | <<<span / d>>>; |
| 27 |