varch/test/test_date.c
2024-11-15 00:31:10 +08:00

70 lines
1.6 KiB
C

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "init.h"
#include "date.h"
#if 0
static int century_days(int century)
{
int days = 0;
int year = (century - 1) * 100 + 1;
for (int i = 0; i < 100; i++)
{
days += date_year_days(year + i);
}
return days;
}
static int thousand2_days(int base)
{
int days = 0;
for (int i = 0; i < 2000; i++)
{
days += date_year_days(base + i);
}
return days;
}
static int thousand3_days(int base)
{
int days = 0;
int century = (base / 100) + 1;
for (int i = 0; i < 20; i++)
{
// days += century_days(century + i);
days += date_century_days(century + i);
}
return days;
}
#endif
static void test(void)
{
printf("month days %d\r\n", date_month_days(2024, 11));
printf("date_isleap %d\r\n", date_isleap(1582));
// printf("date_current_days %d\r\n", date_current_days(DATE(1,1,1)));
// printf("date_current_days %d\r\n", date_current_days(DATE(2000,12,31)));
// printf("date_current_days %d\r\n", date_current_days(DATE(2001,1,1)));
// printf("date_current_days %d\r\n", date_current_days(DATE(2024,11,9)));
printf("date_get_week %d\r\n", date_get_week(DATE(2024,11,11)));
printf("date_diff_days %d\r\n", date_diff_days(DATE(2018,3,14), DATE(2024,11,10)));
// DATE date = date_from_days(date_current_days(DATE(2024,11,30)));
DATE date = date_offset(DATE(2024,11,30), -1);
printf("%d.%d.%d\r\n", date.year,date.month,date.day);
date_show(1998,7);
date_show(2024,11);
date_show(2224,11);
}
init_export_app(test);