提交 f4cd40ef 编写于 作者: Y yinsuo 提交者: skylarCai

support sntp interface. #1657

上级 65d4becc
......@@ -33,8 +33,7 @@ STATIC mp_obj_t mp_sntp_settime(size_t n_args, const mp_obj_t *args)
tz.tz_minuteswest = -480;
tz.tz_dsttime = 0;
sntp_set_timezone(&tz);
return MP_OBJ_NEW_SMALL_INT(0);
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_sntp_settime_obj, 0, 2, mp_sntp_settime);
......
......@@ -76,7 +76,7 @@ STATIC mp_obj_t mp_sntp_settime(size_t n_args, const mp_obj_t *args)
strftime(strftime_buf, sizeof(strftime_buf), "%c", &timeinfo);
ESP_LOGI(TAG, "The current date/time in China is: %s", strftime_buf);
return MP_OBJ_NEW_SMALL_INT(0);
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_sntp_settime_obj, 0, 2, mp_sntp_settime);
......
# sntp - 获取并设定ntp时间
- 模块功能:
获取并设定ntp时间
## setTime - 设置时间
- 函数功能:
指定时区(默认“CST-8”)或者授时服务器(默认“cn.pool.ntp.org”),获取并设定ntp时间。
- 函数原型:
> sntp.setTime([zone], [ntp_server_addr])
- 参数说明:
| 参数 | 类型 | 必选参数? | 说明 |
| --- | --- | --- | --- |
| zone | string | 否 | 时区信息 |
| ntp_server_addr | string | 否 | 授时服务器地址 |
- 返回值:
- 示例:
```python
import sntp
sntp.setTime("CST-8", "cn.pool.ntp.org")
```
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册