File: platform.ck

package info (click to toggle)
chuck 1.5.5.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 41,056 kB
  • sloc: cpp: 123,473; ansic: 35,893; javascript: 2,111; yacc: 609; makefile: 457; python: 174; perl: 86
file content (25 lines) | stat: -rw-r--r-- 1,183 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// name: platform.ck
// desc: getting the operating system name + OS-provided time
// author: Andrew Zhu Aday
// date: summer 2025

// print the underlying operating system name as a string;
// possible return values of Machine.os():
//   "mac", "linux", "windows", "web", "ios", "android", "unknown"
<<< "underlying operating system:", Machine.os() >>>;

// print the operating system-provided absolute time as a float
// in seconds since the Epoch 1970-01-01 00:00:00 +0000 (UTC);
// the returned time has microsecond resolution (and could be
// used for e.g. synchronizing events across machines without
// the use of networking)
<<< "machine time:", Machine.timeOfDay() >>>;

// identical to Machine.timeOfDay(), only the return value is a 
// vec2 where x is time in seconds, and y is fractional time in
// microseconds; y is guaranteed to be between 0 and 1,000,000;
// x + y yields the total time. useful for situations needing less
// than 64-bit precision e.g., floats in OSC are 32-bit and one
// must send the x and y values separately -- otherwise a
// significant amount of timing resolution will be lost
<<< "machine time (added precision):", Machine.timeOfDay2() >>>;