Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
4
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
T
time-slime
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Michael Rouse
time-slime
Commits
17c1b981
Commit
17c1b981
authored
Aug 19, 2018
by
Michael Rouse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Hours method
parent
31c009bc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
9 deletions
+54
-9
shell/shell.c
shell/shell.c
+1
-0
timeslime.c
timeslime.c
+46
-5
timeslime.h
timeslime.h
+7
-4
No files found.
shell/shell.c
View file @
17c1b981
...
...
@@ -13,6 +13,7 @@ int main(int argc, char *argv[])
{
TimeSlime_Initialize
(
"build"
);
TimeSlime_AddHours
(
2
.
3
,
TIMESLIME_DATE_NOW
);
TimeSlime_Close
();
return
0
;
}
\ No newline at end of file
timeslime.c
View file @
17c1b981
...
...
@@ -35,7 +35,9 @@ TIMESLIME_STATUS_t TimeSlime_Initialize(char directory_for_database[])
return
_TimeSlime_CreateTables
();
}
/* Safely close out of the Time Slime library */
/**
* Safely close the Time Slime library
*/
TIMESLIME_STATUS_t
TimeSlime_Close
(
void
)
{
if
(
db
!=
NULL
)
...
...
@@ -51,8 +53,42 @@ TIMESLIME_STATUS_t TimeSlime_Close(void)
}
/* Add to the Time Slime time sheet */
TIMESLIME_STATUS_t
TimeSlime_Add
(
in
t
hours
,
int
year
,
int
month
,
int
day
)
TIMESLIME_STATUS_t
TimeSlime_Add
Hours
(
floa
t
hours
,
int
year
,
int
month
,
int
day
)
{
char
*
errMsg
;
char
sql
[
1000
];
int
rc
;
if
(
month
<
0
||
month
>
12
)
return
TIMESLIME_INVALID_MONTH
;
if
(
day
<
0
||
day
>
31
)
return
TIMESLIME_INVALID_DAY
;
if
((
year
==
0
)
||
(
month
==
0
)
||
(
day
==
0
))
{
// Use current database date
sprintf
(
sql
,
"INSERT INTO TimeSheet "
\
"(HoursAdded, HoursAddedDate) "
\
"VALUES "
\
"(%.2f, DATE('now', 'localtime'))"
,
hours
);
}
else
{
// Use user-specified date
sprintf
(
sql
,
"INSERT INTO TimeSheet "
\
"(HoursAdded, HoursAddedDate) "
\
"VALUES "
\
"(%.2f, '%d/%d/%d')"
,
hours
,
year
,
month
,
day
);
}
rc
=
sqlite3_exec
(
db
,
sql
,
NULL
,
0
,
&
errMsg
);
if
(
rc
!=
SQLITE_OK
)
{
return
TIMESLIME_SQLITE_ERROR
;
}
return
TIMESLIME_OK
;
}
...
...
@@ -248,7 +284,7 @@ static int callback(void *NotUsed, int argc, char **argv, char **azColName) {
*/
static
TIMESLIME_STATUS_t
_TimeSlime_CreateTables
(
void
)
{
char
*
zE
rrMsg
=
0
;
char
*
e
rrMsg
=
0
;
int
rc
;
char
*
sql
;
...
...
@@ -256,11 +292,16 @@ static TIMESLIME_STATUS_t _TimeSlime_CreateTables(void)
sql
=
"CREATE TABLE TimeSheet("
\
"ID INTEGER PRIMARY KEY AUTOINCREMENT,"
\
"HoursAdded REAL NOT NULL DEFAULT 0,"
\
"HoursAddedDate DATE DEFAULT NULL,"
\
"ClockInTime DATETIME DEFAULT NULL,"
\
"ClockOutTime DATETIME DEFAULT NULL,"
\
"Timestamp DATETIME DEFAULT (DATETIME('now', 'localtime'))"
\
")"
;
rc
=
sqlite3_exec
(
db
,
sql
,
NULL
,
0
,
&
zErrMsg
);
"); "
\
"CREATE INDEX HoursAdded_Index ON TimeSheet (HoursAddedDate);"
\
"CREATE INDEX ClockIn_Index ON TimeSheet (ClockInTime);"
\
"CREATE INDEX ClockOut_Index ON TimeSheet (ClockOutTime);"
;
rc
=
sqlite3_exec
(
db
,
sql
,
NULL
,
0
,
&
errMsg
);
if
(
rc
!=
SQLITE_OK
)
{
return
TIMESLIME_SQLITE_ERROR
;
...
...
timeslime.h
View file @
17c1b981
...
...
@@ -16,9 +16,10 @@ typedef int TIMESLIME_STATUS_t;
/* Constants */
/* These are used when you want to use the current date */
#define TIMESLIME_NOW 0, 0, 0
#define TIMESLIME_CLOCK_IN_NOW TIMESLIME_NOW, 0, 0
#define TIMESLIME_CLOCK_OUT_NOW TIMESLIME_NOW, 0, 0
#define TIMESLIME_DATE_NOW 0, 0, 0
#define TIMESLIME_TIME_NOW 0, 0
#define TIMESLIME_CLOCK_IN_NOW TIMESLIME_DATE_NOW, TIMESLIME_TIME_NOW
#define TIMESLIME_CLOCK_OUT_NOW TIMESLIME_DATE_NOW, TIMESLIME_TIME_NOW
/* Result Codes */
#define TIMESLIME_OK 0
...
...
@@ -41,7 +42,7 @@ TIMESLIME_STATUS_t TimeSlime_Initialize(char directory_for_database[]);
TIMESLIME_STATUS_t
TimeSlime_Close
(
void
);
/* Add to the Time Slime time sheet */
TIMESLIME_STATUS_t
TimeSlime_Add
(
in
t
hours
,
int
year
,
int
month
,
int
day
);
TIMESLIME_STATUS_t
TimeSlime_Add
Hours
(
floa
t
hours
,
int
year
,
int
month
,
int
day
);
/* Clock in to the Time Slime time sheet */
TIMESLIME_STATUS_t
TimeSlime_ClockIn
(
int
year
,
int
month
,
int
day
,
int
hour
,
int
minute
);
...
...
@@ -49,5 +50,7 @@ TIMESLIME_STATUS_t TimeSlime_ClockIn(int year, int month, int day, int hour, int
/* Clock out of the Time Slime time sheet */
TIMESLIME_STATUS_t
TimeSlime_ClockOut
(
int
year
,
int
month
,
int
day
,
int
hour
,
int
minute
);
/* Gets the time sheet for a period of time */
TIMESLIME_STATUS_t
TimeSlime_GetTimeSheet
(
void
);
#endif
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment