Reworked track settings.
[demorecorder] / src / Constants.vala
1 /*  Demo Recorder for MAEMO 5
2 *   Copyright (C) 2010 Dru Moore <usr@dru-id.co.uk>
3 *   This program is free software; you can redistribute it and/or modify
4 *   it under the terms of the GNU General Public License version 2,
5 *   or (at your option) any later version, as published by the Free
6 *   Software Foundation
7 *
8 *   This program is distributed in the hope that it will be useful,
9 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
10 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 *   GNU General Public License for more details
12 *
13 *   You should have received a copy of the GNU General Public
14 *   License along with this program; if not, write to the
15 *   Free Software Foundation, Inc.,
16 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17 */
18 namespace IdWorks {
19
20   namespace Time {
21
22     public const string CLOCK_FORMAT = "%02llu:%02llu.%01llu";
23     public static string time_to_string(int64 t) {
24       uint64 ut = (uint64)t / Nanoseconds.MILLISECOND;
25       return CLOCK_FORMAT.printf((ut / Milliseconds.MINUTE), (ut / Milliseconds.SECOND) % Seconds.MINUTE, (ut % Milliseconds.SECOND) / 100);
26     }
27     public static int64 get_current_time() {
28       TimeVal tv = TimeVal();
29       tv.get_current_time();
30       return (((int64)tv.tv_sec * 1000000) + (int64)tv.tv_usec) * 1000;
31     }
32
33     namespace Nanoseconds {
34       public const uint64 NANOSECOND = 1;
35       public const uint64 MILLISECOND = 1000000 * NANOSECOND;
36       public const uint64 SECOND = 1000 * MILLISECOND;
37       public const uint64 MINUTE = 60 * SECOND;
38       public const uint64 HOUR = 60 * MINUTE;
39       public const uint64 DAY = 24 * HOUR;
40       public const uint64 WEEK = 7 * DAY;
41     }
42
43     namespace Milliseconds {
44       public const uint64 MILLISECOND = 1;
45       public const uint64 SECOND = 1000 * MILLISECOND;
46       public const uint64 MINUTE = 60 * SECOND;
47       public const uint64 HOUR = 60 * MINUTE;
48       public const uint64 DAY = 24 * HOUR;
49       public const uint64 WEEK = 7 * DAY;
50     }
51
52     namespace Seconds {
53       public const uint64 SECOND = 1;
54       public const uint64 MINUTE = 60 * SECOND;
55       public const uint64 HOUR = 60 * MINUTE;
56       public const uint64 DAY = 24 * HOUR;
57       public const uint64 WEEK = 7 * DAY;
58     }
59
60   }
61
62 }