Revision 1, 1.1 kB
(checked in by jinshiro, 17 years ago)
|
|
Rev | Line | |
---|
[1] | 1 | // Copyright (c) Athena Dev Teams - Licensed under GNU GPL |
---|
| 2 | // For more information, see LICENCE in the main folder |
---|
| 3 | |
---|
| 4 | #include "date.h" |
---|
| 5 | #include <time.h> |
---|
| 6 | |
---|
| 7 | int date_get_year(void) |
---|
| 8 | { |
---|
| 9 | time_t t; |
---|
| 10 | struct tm * lt; |
---|
| 11 | t = time(NULL); |
---|
| 12 | lt = localtime(&t); |
---|
| 13 | return lt->tm_year+1900; |
---|
| 14 | } |
---|
| 15 | int date_get_month(void) |
---|
| 16 | { |
---|
| 17 | time_t t; |
---|
| 18 | struct tm * lt; |
---|
| 19 | t = time(NULL); |
---|
| 20 | lt = localtime(&t); |
---|
| 21 | return lt->tm_mon+1; |
---|
| 22 | } |
---|
| 23 | int date_get_day(void) |
---|
| 24 | { |
---|
| 25 | time_t t; |
---|
| 26 | struct tm * lt; |
---|
| 27 | t = time(NULL); |
---|
| 28 | lt = localtime(&t); |
---|
| 29 | return lt->tm_mday; |
---|
| 30 | } |
---|
| 31 | int date_get_hour(void) |
---|
| 32 | { |
---|
| 33 | time_t t; |
---|
| 34 | struct tm * lt; |
---|
| 35 | t = time(NULL); |
---|
| 36 | lt = localtime(&t); |
---|
| 37 | return lt->tm_hour; |
---|
| 38 | } |
---|
| 39 | |
---|
| 40 | int date_get_min(void) |
---|
| 41 | { |
---|
| 42 | time_t t; |
---|
| 43 | struct tm * lt; |
---|
| 44 | t = time(NULL); |
---|
| 45 | lt = localtime(&t); |
---|
| 46 | return lt->tm_min; |
---|
| 47 | } |
---|
| 48 | |
---|
| 49 | int date_get_sec(void) |
---|
| 50 | { |
---|
| 51 | time_t t; |
---|
| 52 | struct tm * lt; |
---|
| 53 | t = time(NULL); |
---|
| 54 | lt = localtime(&t); |
---|
| 55 | return lt->tm_sec; |
---|
| 56 | } |
---|
| 57 | |
---|
| 58 | int is_day_of_sun(void) |
---|
| 59 | { |
---|
| 60 | return date_get_day()%2 == 0; |
---|
| 61 | } |
---|
| 62 | |
---|
| 63 | int is_day_of_moon(void) |
---|
| 64 | { |
---|
| 65 | return date_get_day()%2 == 1; |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | int is_day_of_star(void) |
---|
| 69 | { |
---|
| 70 | return date_get_day()%5 == 0; |
---|
| 71 | } |
---|