mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-28 07:03:00 +08:00
fix(calendar): fix lv_calendar_gregorian_to_chinese compile error (#6894)
Signed-off-by: lhdjply <lhdjply@126.com>
This commit is contained in:
parent
4415f6e6de
commit
40577fe685
@ -70,7 +70,6 @@ extern "C" {
|
||||
#include "widgets/buttonmatrix/lv_buttonmatrix_private.h"
|
||||
#include "widgets/slider/lv_slider_private.h"
|
||||
#include "widgets/switch/lv_switch_private.h"
|
||||
#include "widgets/calendar/lv_calendar_chinese_private.h"
|
||||
#include "widgets/calendar/lv_calendar_private.h"
|
||||
#include "widgets/imagebutton/lv_imagebutton_private.h"
|
||||
#include "widgets/bar/lv_bar_private.h"
|
||||
|
@ -185,8 +185,6 @@ typedef struct _lv_buttonmatrix_t lv_buttonmatrix_t;
|
||||
|
||||
typedef struct _lv_calendar_t lv_calendar_t;
|
||||
|
||||
typedef struct _lv_calendar_chinese_t lv_calendar_chinese_t;
|
||||
|
||||
typedef struct _lv_canvas_t lv_canvas_t;
|
||||
|
||||
typedef struct _lv_chart_series_t lv_chart_series_t;
|
||||
|
@ -6,7 +6,6 @@
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_calendar_chinese_private.h"
|
||||
#include "lv_calendar_private.h"
|
||||
#if LV_USE_CALENDAR && LV_USE_CALENDAR_CHINESE
|
||||
|
||||
@ -124,7 +123,7 @@ const char * lv_calendar_get_day_name(lv_calendar_date_t * gregorian)
|
||||
{
|
||||
uint16_t i, len;
|
||||
lv_calendar_chinese_t chinese_calendar;
|
||||
chinese_calendar = lv_calendar_gregorian_to_chinese(gregorian);
|
||||
lv_calendar_gregorian_to_chinese(gregorian, &chinese_calendar);
|
||||
|
||||
if(gregorian->year > 2099 || gregorian->year < 1901)
|
||||
return NULL;
|
||||
@ -170,11 +169,11 @@ const char * lv_calendar_get_day_name(lv_calendar_date_t * gregorian)
|
||||
return (char *)chinese_calendar_day_name[chinese_calendar.today.day - 1];
|
||||
}
|
||||
|
||||
lv_calendar_chinese_t lv_calendar_gregorian_to_chinese(lv_calendar_date_t * gregorian)
|
||||
void lv_calendar_gregorian_to_chinese(lv_calendar_date_t * gregorian_time, lv_calendar_chinese_t * chinese_time)
|
||||
{
|
||||
uint16_t year = gregorian->year;
|
||||
uint8_t month = gregorian->month;
|
||||
uint8_t day = gregorian->day;
|
||||
uint16_t year = gregorian_time->year;
|
||||
uint8_t month = gregorian_time->month;
|
||||
uint8_t day = gregorian_time->day;
|
||||
|
||||
/*Record the number of days between the Spring Festival
|
||||
and the New Year's Day of that year.*/
|
||||
@ -191,14 +190,13 @@ lv_calendar_chinese_t lv_calendar_gregorian_to_chinese(lv_calendar_date_t * greg
|
||||
uint8_t index;
|
||||
|
||||
bool leep_month;
|
||||
lv_calendar_chinese_t chinese_calendar;
|
||||
|
||||
if(year < 1901 || year > 2099) {
|
||||
chinese_calendar.leep_month = 0;
|
||||
chinese_calendar.today.year = 2000;
|
||||
chinese_calendar.today.month = 1;
|
||||
chinese_calendar.today.day = 1;
|
||||
return chinese_calendar;
|
||||
chinese_time->leep_month = 0;
|
||||
chinese_time->today.year = 2000;
|
||||
chinese_time->today.month = 1;
|
||||
chinese_time->today.day = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
if(((calendar_chinese_table[year - 1901] & 0x0060) >> 5) == 1)
|
||||
@ -274,11 +272,10 @@ lv_calendar_chinese_t lv_calendar_gregorian_to_chinese(lv_calendar_date_t * greg
|
||||
|
||||
day = days_per_month - by_spring + 1;
|
||||
}
|
||||
chinese_calendar.today.day = day;
|
||||
chinese_calendar.today.month = month;
|
||||
chinese_calendar.today.year = year;
|
||||
chinese_calendar.leep_month = leep_month;
|
||||
return chinese_calendar;
|
||||
chinese_time->today.day = day;
|
||||
chinese_time->today.month = month;
|
||||
chinese_time->today.year = year;
|
||||
chinese_time->leep_month = leep_month;
|
||||
}
|
||||
|
||||
/**********************
|
||||
|
@ -21,6 +21,15 @@ extern "C" {
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef struct {
|
||||
lv_calendar_date_t today;
|
||||
bool leep_month;
|
||||
} lv_calendar_chinese_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
@ -41,10 +50,10 @@ const char * lv_calendar_get_day_name(lv_calendar_date_t * gregorian);
|
||||
|
||||
/**
|
||||
* Get the chinese time of the gregorian time (reference: https://www.cnblogs.com/liyang31tg/p/4123171.html)
|
||||
* @param gregorian need to convert to chinese time in gregorian time
|
||||
* @return return the chinese time of the gregorian time
|
||||
* @param gregorian_time need to convert to chinese time in gregorian time
|
||||
* @param chinese_time the chinese time convert from gregorian time
|
||||
*/
|
||||
lv_calendar_chinese_t lv_calendar_gregorian_to_chinese(lv_calendar_date_t * gregorian);
|
||||
void lv_calendar_gregorian_to_chinese(lv_calendar_date_t * gregorian_time, lv_calendar_chinese_t * chinese_time);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
|
@ -1,53 +0,0 @@
|
||||
/**
|
||||
* @file lv_calendar_chinese_private.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_CALENDAR_CHINESE_PRIVATE_H
|
||||
#define LV_CALENDAR_CHINESE_PRIVATE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "lv_calendar_chinese.h"
|
||||
|
||||
#if LV_USE_CALENDAR && LV_USE_CALENDAR_CHINESE
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
struct _lv_calendar_chinese_t {
|
||||
lv_calendar_date_t today;
|
||||
bool leep_month;
|
||||
};
|
||||
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /* LV_USE_CALENDAR && LV_USE_CALENDAR_CHINESE */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_CALENDAR_CHINESE_PRIVATE_H*/
|
Loading…
x
Reference in New Issue
Block a user