Skip to content

Commit 1f85f0b

Browse files
authored
[k2] update k2-header (#1324)
add two functions * k2_set_timezone * k2_localtime_r
1 parent 2ae9ab7 commit 1f85f0b

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

runtime-light/k2-platform/k2-header.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@
1414
#include <atomic>
1515
#include <cstdint>
1616
#include <cstring>
17+
#include <ctime>
1718
#else
1819
#include <stdatomic.h>
1920
#include <stdint.h>
2021
#include <string.h>
22+
#include <time.h>
2123
#endif
2224

2325
#define K2_PLATFORM_HEADER_H_VERSION 11
@@ -436,6 +438,20 @@ void k2_env_fetch(uint32_t env_num, char* key, char* value);
436438

437439
// ---- libc analogues, designed to work instance-local ----
438440

441+
/**
442+
* Works instance-local.
443+
* Analogue of tzset(), but accept locale explicitly.
444+
* @return: `0` on success, non-zero otherwise
445+
*/
446+
int32_t k2_set_timezone(const char* timezone);
447+
448+
/**
449+
* Works instance-local.
450+
* Analogue of localtime_r().
451+
* @return: `result` on success, `NULL` otherwise
452+
*/
453+
struct tm* k2_localtime_r(const time_t* timer, struct tm* result);
454+
439455
/**
440456
* Works instance-local.
441457
* Does not return previous locale.

0 commit comments

Comments
 (0)