-
Notifications
You must be signed in to change notification settings - Fork 0
/
date.h
70 lines (61 loc) · 1.7 KB
/
date.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
60
61
62
63
64
65
66
67
68
69
70
#ifndef DATE_H_
#define DATE_H_
#include <stdbool.h>
/** Type for defining the date */
typedef struct Date_t *Date;
/**
* dateCreate: Allocates a new date.
*
* @param day - the day of the date.
* @param month - the month of the date.
* @param year - the year of the date.
* @return
* nullptr - if allocation failed or date is illegal.
* A new Date in case of success.
*/
Date dateCreate(int day, int month, int year);
/**
* dateDestroy: Deallocates an existing Date.
*
* @param date - Target date to be deallocated. If priority queue is nullptr nothing will be done
*/
void dateDestroy(Date date);
/**
* dateCopy: Creates a copy of target Date.
*
* @param date - Target Date.
* @return
* nullptr if a nullptr was sent or a memory allocation failed.
* A Date containing the same elements as date otherwise.
*/
Date dateCopy(Date date);
/**
* dateGet: Returns the day, month and year of a date
*
* @param date - Target Date
* @param day - the pointer to assign to day of the date into.
* @param month - the pointer to assign to month of the date into.
* @param year - the pointer to assign to year of the date into.
*
* @return
* false if one of pointers is nullptr.
* Otherwise true and the date is assigned to the pointers.
*/
bool dateGet(Date date, int* day, int* month, int* year);
/**
* dateCompare: compares to dates and return which comes first
*
* @return
* A negative integer if date1 occurs first;
* 0 if they're equal or one of the given dates is nullptr;
* A positive integer if date1 arrives after date2.
*/
int dateCompare(Date date1, Date date2);
/**
* dateTick: increases the date by one day, if date is nullptr should do nothing.
*
* @param date - Target Date
*
*/
void dateTick(Date date);
#endif //DATE_H_