Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions components/py_engine/modules/sntp/aos/modsntp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion components/py_engine/modules/sntp/esp32/modsntp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
33 changes: 33 additions & 0 deletions haas_lib_bundles/python/docs/haas_extended_api/sntp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# 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")

```