Skip to content

date_time_t

概述

日期时间。

在嵌入式平台中,在系统初始时,需要调用date_time_global_init设置实际获取/设置系统时间的函数。

函数

函数名称说明
date_time_add_delta加上一个偏移量(s)。
date_time_create创建date_time对象,并初始为当前日期和时间(一般供脚本语言中使用)。
date_time_destroy销毁date_time对象(一般供脚本语言中使用)。
date_time_from_time从time转换而来(按GMT转换)。
date_time_get_days获取指定年份月份的天数。
date_time_get_month_name获取指定月份的英文名称(简写)。
date_time_get_wday获取指定日期是周几(0-6, Sunday = 0)。。
date_time_get_wday_name获取周几的英文名称(简写)。
date_time_global_init_ex时间日期全局初始化。
date_time_init初始为当前日期和时间。
date_time_is_leap是否是闰年。
date_time_parse_date解析日期。
date_time_parse_date_time解析日期和时间。
date_time_parse_time解析时间。
date_time_set设置当前时间。
date_time_set_day设置日。
date_time_set_hour设置小时。
date_time_set_minute设置分钟。
date_time_set_month设置月。
date_time_set_second设置秒。
date_time_set_year设置年。
date_time_to_time转换成time(按GMT转换)。

属性

属性名称类型说明
dayint32_t日(1-31)。
hourint32_t时(0 - 23)。
minuteint32_t分(0 - 59)。
monthint32_t月(1-12)。
secondint32_t秒(0 - 59)。
wdayint32_t星期几(0-6, Sunday = 0)。
yearint32_t年。

date_time_add_delta 函数

  • 函数功能:

加上一个偏移量(s)。

  • 函数原型:
ret_t date_time_add_delta (date_time_t* dt, int64_t delta);
  • 参数说明:
参数类型说明
返回值ret_t返回RET_OK表示成功,否则表示失败。
dtdate_time_t*date_time对象。
deltaint64_t偏移量(s)。

date_time_create 函数

  • 函数功能:

创建date_time对象,并初始为当前日期和时间(一般供脚本语言中使用)。

  • 函数原型:
date_time_t* date_time_create ();
  • 参数说明:
参数类型说明
返回值date_time_t*返回date_time对象。

date_time_destroy 函数

  • 函数功能:

销毁date_time对象(一般供脚本语言中使用)。

  • 函数原型:
ret_t date_time_destroy (date_time_t* dt);
  • 参数说明:
参数类型说明
返回值ret_t返回RET_OK表示成功,否则表示失败。
dtdate_time_t*date_time对象。

date_time_from_time 函数

  • 函数功能:

从time转换而来(按GMT转换)。

  • 函数原型:
ret_t date_time_from_time (date_time_t* dt, int64_t time);
  • 参数说明:
参数类型说明
返回值ret_t返回RET_OK表示成功,否则表示失败。
dtdate_time_t*date_time对象。
timeint64_t时间。

date_time_get_days 函数

  • 函数功能:

获取指定年份月份的天数。

  • 函数原型:
int32_t date_time_get_days (uint32_t year, uint32_t month);
  • 参数说明:
参数类型说明
返回值int32_t返回大于0表示天数,否则表示失败。
yearuint32_t年份。
monthuint32_t月份(1-12)。

date_time_get_month_name 函数

  • 函数功能:

获取指定月份的英文名称(简写)。

  • 函数原型:
const char* date_time_get_month_name (uint32_t month);
  • 参数说明:
参数类型说明
返回值const char*返回指定月份的英文名称(简写)。
monthuint32_t月份(1-12)。

date_time_get_wday 函数

  • 函数功能:

获取指定日期是周几(0-6, Sunday = 0)。。

  • 函数原型:
int32_t date_time_get_wday (uint32_t year, uint32_t month, uint32_t day);
  • 参数说明:
参数类型说明
返回值int32_t返回大于等于0表示周几(0-6),否则表示失败。
yearuint32_t年份。
monthuint32_t月份(1-12)。
dayuint32_t日(1-31)。

date_time_get_wday_name 函数

  • 函数功能:

获取周几的英文名称(简写)。

  • 函数原型:
const char* date_time_get_wday_name (uint32_t wday);
  • 参数说明:
参数类型说明
返回值const char*返回指定周几的英文名称(简写)。
wdayuint32_t星期几(0-6, Sunday = 0)。

date_time_global_init_ex 函数

  • 函数功能:

时间日期全局初始化。

嵌入式平台需要提供并设置获取当前日期和时间的函数,否则相关的功能(如时钟控件)将无法正常工作。

  • 函数原型:
ret_t date_time_global_init_ex (const date_time_vtable_t* vt);
  • 参数说明:
参数类型说明
返回值ret_t返回RET_OK表示成功,否则表示失败。
vtconst date_time_vtable_t*日期和时间的相关函数的实现。

date_time_init 函数

  • 函数功能:

初始为当前日期和时间。

  • 函数原型:
date_time_t* date_time_init (date_time_t* dt);
  • 参数说明:
参数类型说明
返回值date_time_t*返回date_time对象。
dtdate_time_t*date_time对象。

date_time_is_leap 函数

  • 函数功能:

是否是闰年。

  • 函数原型:
bool_t date_time_is_leap (uint32_t year);
  • 参数说明:
参数类型说明
返回值bool_t返回TRUE表示是,否则表示否。
yearuint32_t年份。

date_time_parse_date 函数

  • 函数功能:

解析日期。

  • 函数原型:
ret_t date_time_parse_date (date_time_t* dt, const char* str);
  • 参数说明:
参数类型说明
返回值ret_t返回RET_OK表示成功,否则表示失败。
dtdate_time_t*date_time对象。
strconst char*日期字符串。

date_time_parse_date_time 函数

  • 函数功能:

解析日期和时间。

  • 函数原型:
ret_t date_time_parse_date_time (date_time_t* dt, const char* str);
  • 参数说明:
参数类型说明
返回值ret_t返回RET_OK表示成功,否则表示失败。
dtdate_time_t*date_time对象。
strconst char*日期和时间字符串。

date_time_parse_time 函数

  • 函数功能:

解析时间。

  • 函数原型:
ret_t date_time_parse_time (date_time_t* dt, const char* str);
  • 参数说明:
参数类型说明
返回值ret_t返回RET_OK表示成功,否则表示失败。
dtdate_time_t*date_time对象。
strconst char*时间字符串。

date_time_set 函数

  • 函数功能:

设置当前时间。

  • 函数原型:
ret_t date_time_set (date_time_t* dt);
  • 参数说明:
参数类型说明
返回值ret_t返回RET_OK表示成功,否则表示失败。
dtdate_time_t*date_time对象。

date_time_set_day 函数

  • 函数功能:

设置日。

  • 函数原型:
ret_t date_time_set_day (date_time_t* dt, uint32_t day);
  • 参数说明:
参数类型说明
返回值ret_t返回RET_OK表示成功,否则表示失败。
dtdate_time_t*date_time对象。
dayuint32_t日。

date_time_set_hour 函数

  • 函数功能:

设置小时。

  • 函数原型:
ret_t date_time_set_hour (date_time_t* dt, uint32_t hour);
  • 参数说明:
参数类型说明
返回值ret_t返回RET_OK表示成功,否则表示失败。
dtdate_time_t*date_time对象。
houruint32_t小时。

date_time_set_minute 函数

  • 函数功能:

设置分钟。

  • 函数原型:
ret_t date_time_set_minute (date_time_t* dt, uint32_t minute);
  • 参数说明:
参数类型说明
返回值ret_t返回RET_OK表示成功,否则表示失败。
dtdate_time_t*date_time对象。
minuteuint32_t分钟。

date_time_set_month 函数

  • 函数功能:

设置月。

  • 函数原型:
ret_t date_time_set_month (date_time_t* dt, uint32_t month);
  • 参数说明:
参数类型说明
返回值ret_t返回RET_OK表示成功,否则表示失败。
dtdate_time_t*date_time对象。
monthuint32_t月。

date_time_set_second 函数

  • 函数功能:

设置秒。

  • 函数原型:
ret_t date_time_set_second (date_time_t* dt, uint32_t second);
  • 参数说明:
参数类型说明
返回值ret_t返回RET_OK表示成功,否则表示失败。
dtdate_time_t*date_time对象。
seconduint32_t秒。

date_time_set_year 函数

  • 函数功能:

设置年。

  • 函数原型:
ret_t date_time_set_year (date_time_t* dt, uint32_t year);
  • 参数说明:
参数类型说明
返回值ret_t返回RET_OK表示成功,否则表示失败。
dtdate_time_t*date_time对象。
yearuint32_t年。

date_time_to_time 函数

  • 函数功能:

转换成time(按GMT转换)。

  • 函数原型:
int64_t date_time_to_time (date_time_t* dt);
  • 参数说明:
参数类型说明
返回值int64_t返回time。
dtdate_time_t*date_time对象。

day 属性

日(1-31)。

  • 类型:int32_t
特性是否支持
可直接读取
可直接修改
可脚本化

hour 属性

时(0 - 23)。

  • 类型:int32_t
特性是否支持
可直接读取
可直接修改
可脚本化

minute 属性

分(0 - 59)。

  • 类型:int32_t
特性是否支持
可直接读取
可直接修改
可脚本化

month 属性

月(1-12)。

  • 类型:int32_t
特性是否支持
可直接读取
可直接修改
可脚本化

second 属性

秒(0 - 59)。

  • 类型:int32_t
特性是否支持
可直接读取
可直接修改
可脚本化

wday 属性

星期几(0-6, Sunday = 0)。

  • 类型:int32_t
特性是否支持
可直接读取
可直接修改
可脚本化

year 属性

年。

  • 类型:int32_t
特性是否支持
可直接读取
可直接修改
可脚本化