forked from unixwitch/tts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entry.h
59 lines (48 loc) · 1.31 KB
/
entry.h
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
* TTS - track your time.
* Copyright (c) 2012-2014 Felicity Tarnell.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely. This software is provided 'as-is', without any express or implied
* warranty.
*/
#ifndef TTS_ENTRY_H
#define TTS_ENTRY_H
#include <time.h>
#include "tailq.h"
#include "wide.h"
typedef struct entry {
wchar_t *en_desc;
int en_secs;
time_t en_started;
time_t en_created;
struct {
int efl_visible:1;
int efl_invoiced:1;
int efl_marked:1;
int efl_deleted:1;
int efl_nonbillable:1;
} en_flags;
TTS_TAILQ_ENTRY(entry) en_entries;
} entry_t;
typedef TTS_TAILQ_HEAD(entrylist, entry) entry_list;
extern entry_list entries;
extern entry_t *running;
entry_t *entry_new (const wchar_t *);
void entry_start (entry_t *);
void entry_stop (entry_t *);
void entry_free (entry_t *);
void entry_account (entry_t *);
time_t entry_time_for_day (time_t, int, int);
#define time_day(t) (((t) / (60 * 60 * 24)) * (60 * 60 * 24))
#define entry_day(e) (time_day((e)->en_created))
#define time_to_hms(t, h, m, s) do { \
time_t n = t; \
h = n / (60 * 60); \
n %= (60 * 60); \
m = n / 60; \
n %= 60; \
s = n; \
} while (0)
#endif /* !TTS_ENTRY_H */