set_tz.c

C语言时区设置示例
本文通过一个C语言程序示例介绍了如何设置和获取当前系统时区信息。该程序使用了putenv, tzset及printf等函数来展示当前时区(如PST8PDT)以及夏令时设置(如果存在)。这对于理解C语言中时间和日期操作的基础非常有用。

  name="google_ads_frame" marginwidth="0" marginheight="0" src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-5572165936844014&dt=1194442938015&lmt=1194190197&format=336x280_as&output=html&correlator=1194442937843&url=file%3A%2F%2F%2FC%3A%2FDocuments%2520and%2520Settings%2Flhh1%2F%E6%A1%8C%E9%9D%A2%2FCLanguage.htm&color_bg=FFFFFF&color_text=000000&color_link=000000&color_url=FFFFFF&color_border=FFFFFF&ad_type=text&ga_vid=583001034.1194442938&ga_sid=1194442938&ga_hid=1942779085&flash=9&u_h=768&u_w=1024&u_ah=740&u_aw=1024&u_cd=32&u_tz=480&u_java=true" frameborder="0" width="336" scrolling="no" height="280" allowtransparency="allowtransparency"> #include <stdio.h>
#include <stdlib.h>
#include <time.h>

void main(void)
 {
   putenv("TZ=PST8PDT");

   tzset();

   printf("Current time zone is %s/n", tzname[0]);

   if (tzname[1])
     printf("Daylight savings zone is %s/n", tzname[1]);
   else
     printf("Daylight savings zone is not defined/n");
 }

 

update t_temp_rzcjb_htxh set cjje0 = coalesce(v1.temp - v1.rzcjb, t_temp_rzcjb_htxh.cjje0) from (select * from (select cjhm, cjje0, sjly from t_temp_rzcjb_htxh) a pivot (max(cjje0) for sjly in (temp, rzcjb)) b) v1 where t_temp_rzcjb_htxh.cjhm = v1.cjhm and t_temp_rzcjb_htxh.sjly = 'rzcjb_dvp' and t_temp_rzcjb_htxh.jsfs = '8001' and t_temp_rzcjb_htxh.ywlb not in ('LOFSG_TZ', 'LOFSH_TZ', 'XJTDJS_TZ', 'XJTDZJ_TZ', 'XJYEZJ_TZ', 'XJYEJS_TZ', 'XJTDTK_TZ', 'XJTDBK_TZ', 'SGGPJS_TZ','SHGPZJ_TZ', 'ETFSG_TZ', 'ETFSH_TZ') update t_temp_rzcjb_htxh set cjje1 = coalesce(v1.temp - v1.rzcjb, t_temp_rzcjb_htxh.cjje1) from (select * from (select cjhm, cjje1, sjly from t_temp_rzcjb_htxh) a pivot (max(cjje1) for sjly in (temp, rzcjb)) b) v1 where t_temp_rzcjb_htxh.cjhm = v1.cjhm and t_temp_rzcjb_htxh.sjly = 'rzcjb_dvp' and t_temp_rzcjb_htxh.jsfs = '8001' and t_temp_rzcjb_htxh.ywlb not in ('LOFSG_TZ', 'LOFSH_TZ', 'XJTDJS_TZ', 'XJTDZJ_TZ', 'XJYEZJ_TZ', 'XJYEJS_TZ', 'XJTDTK_TZ', 'XJTDBK_TZ', 'SGGPJS_TZ','SHGPZJ_TZ', 'ETFSG_TZ', 'ETFSH_TZ') update t_temp_rzcjb_htxh set jyfy11 = coalesce(v1.temp - v1.rzcjb, t_temp_rzcjb_htxh.jyfy11) from (select * from (select cjhm, jyfy11, sjly from t_temp_rzcjb_htxh) a pivot (max(jyfy11) for sjly in (temp, rzcjb)) b) v1 where t_temp_rzcjb_htxh.cjhm = v1.cjhm and t_temp_rzcjb_htxh.sjly = 'rzcjb_dvp' and t_temp_rzcjb_htxh.jsfs = '8001' and t_temp_rzcjb_htxh.ywlb not in ('LOFSG_TZ', 'LOFSH_TZ') update t_temp_rzcjb_htxh set jyfy21 = coalesce(v1.temp - v1.rzcjb, t_temp_rzcjb_htxh.jyfy21) from (select * from (select cjhm, jyfy21, sjly from t_temp_rzcjb_htxh) a pivot (max(jyfy21) for sjly in (temp, rzcjb)) b) v1 where t_temp_rzcjb_htxh.cjhm = v1.cjhm and t_temp_rzcjb_htxh.sjly = 'rzcjb_dvp' and t_temp_rzcjb_htxh.jsfs = '8001' and t_temp_rzcjb_htxh.ywlb not in ('LOFSG_TZ', 'LOFSH_TZ') update t_temp_rzcjb_htxh set jyfy31 = coalesce(v1.temp - v1.rzcjb, t_temp_rzcjb_htxh.jyfy31) from (select * from (select cjhm, jyfy31, sjly from t_temp_rzcjb_htxh) a pivot (max(jyfy31) for sjly in (temp, rzcjb)) b) v1 where t_temp_rzcjb_htxh.cjhm = v1.cjhm and t_temp_rzcjb_htxh.sjly = 'rzcjb_dvp' and t_temp_rzcjb_htxh.jsfs = '8001' and t_temp_rzcjb_htxh.ywlb not in ('LOFSG_TZ', 'LOFSH_TZ') update t_temp_rzcjb_htxh set jyfy41 = coalesce(v1.temp - v1.rzcjb, t_temp_rzcjb_htxh.jyfy41) from (select * from (select cjhm, jyfy41, sjly from t_temp_rzcjb_htxh) a pivot (max(jyfy41) for sjly in (temp, rzcjb)) b) v1 where t_temp_rzcjb_htxh.cjhm = v1.cjhm and t_temp_rzcjb_htxh.sjly = 'rzcjb_dvp' and t_temp_rzcjb_htxh.jsfs = '8001' and t_temp_rzcjb_htxh.ywlb not in ('LOFSG_TZ', 'LOFSH_TZ') update t_temp_rzcjb_htxh set jyfy42 = coalesce(v1.temp - v1.rzcjb, t_temp_rzcjb_htxh.jyfy42) from (select * from (select cjhm, jyfy42, sjly from t_temp_rzcjb_htxh) a pivot (max(jyfy42) for sjly in (temp, rzcjb)) b) v1 where t_temp_rzcjb_htxh.cjhm = v1.cjhm and t_temp_rzcjb_htxh.sjly = 'rzcjb_dvp' and t_temp_rzcjb_htxh.jsfs = '8001' and t_temp_rzcjb_htxh.ywlb not in ('LOFSG_TZ', 'LOFSH_TZ') update t_temp_rzcjb_htxh set jyfy43 = coalesce(v1.temp - v1.rzcjb, t_temp_rzcjb_htxh.jyfy43) from (select * from (select cjhm, jyfy43, sjly from t_temp_rzcjb_htxh) a pivot (max(jyfy43) for sjly in (temp, rzcjb)) b) v1 where t_temp_rzcjb_htxh.cjhm = v1.cjhm and t_temp_rzcjb_htxh.sjly = 'rzcjb_dvp' and t_temp_rzcjb_htxh.jsfs = '8001' and t_temp_rzcjb_htxh.ywlb not in ('LOFSG_TZ', 'LOFSH_TZ') update t_temp_rzcjb_htxh set jyfy44 = coalesce(v1.temp - v1.rzcjb, t_temp_rzcjb_htxh.jyfy44) from (select * from (select cjhm, jyfy44, sjly from t_temp_rzcjb_htxh) a pivot (max(jyfy44) for sjly in (temp, rzcjb)) b) v1 where t_temp_rzcjb_htxh.cjhm = v1.cjhm and t_temp_rzcjb_htxh.sjly = 'rzcjb_dvp' and t_temp_rzcjb_htxh.jsfs = '8001' and t_temp_rzcjb_htxh.ywlb not in ('LOFSG_TZ', 'LOFSH_TZ') update t_temp_rzcjb_htxh set jyfy45 = coalesce(v1.temp - v1.rzcjb, t_temp_rzcjb_htxh.jyfy45) from (select * from (select cjhm, jyfy45, sjly from t_temp_rzcjb_htxh) a pivot (max(jyfy45) for sjly in (temp, rzcjb)) b) v1 where t_temp_rzcjb_htxh.cjhm = v1.cjhm and t_temp_rzcjb_htxh.sjly = 'rzcjb_dvp' and t_temp_rzcjb_htxh.jsfs = '8001' and t_temp_rzcjb_htxh.ywlb not in ('LOFSG_TZ', 'LOFSH_TZ') update t_temp_rzcjb_htxh set jyfy81 = coalesce(v1.temp - v1.rzcjb, t_temp_rzcjb_htxh.jyfy81) from (select * from (select cjhm, jyfy81, sjly from t_temp_rzcjb_htxh) a pivot (max(jyfy81) for sjly in (temp, rzcjb)) b) v1 where t_temp_rzcjb_htxh.cjhm = v1.cjhm and t_temp_rzcjb_htxh.sjly = 'rzcjb_dvp' and t_temp_rzcjb_htxh.jsfs = '8001' and t_temp_rzcjb_htxh.ywlb not in ('LOFSG_TZ', 'LOFSH_TZ') update t_temp_rzcjb_htxh set jyfy82 = coalesce(v1.temp - v1.rzcjb, t_temp_rzcjb_htxh.jyfy82) from (select * from (select cjhm, jyfy82, sjly from t_temp_rzcjb_htxh) a pivot (max(jyfy82) for sjly in (temp, rzcjb)) b) v1 where t_temp_rzcjb_htxh.cjhm = v1.cjhm and t_temp_rzcjb_htxh.sjly = 'rzcjb_dvp' and t_temp_rzcjb_htxh.jsfs = '8001' and t_temp_rzcjb_htxh.ywlb not in ('LOFSG_TZ', 'LOFSH_TZ') update t_temp_rzcjb_htxh set jyfy83 = coalesce(v1.temp - v1.rzcjb, t_temp_rzcjb_htxh.jyfy83) from (select * from (select cjhm, jyfy83, sjly from t_temp_rzcjb_htxh) a pivot (max(jyfy83) for sjly in (temp, rzcjb)) b) v1 where t_temp_rzcjb_htxh.cjhm = v1.cjhm and t_temp_rzcjb_htxh.sjly = 'rzcjb_dvp' and t_temp_rzcjb_htxh.jsfs = '8001' and t_temp_rzcjb_htxh.ywlb not in ('LOFSG_TZ', 'LOFSH_TZ')
最新发布
11-26
/* volc rtc example code This example code is in the Public Domain (or CC0 licensed, at your option.) Unless required by applicable law or agreed to in writing, this software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ #include <stdio.h> #include <time.h> #includePath <sys/time.h> #include "freertos/idf_additions.h" #include "nvs_flash.h" #include "esp_event.h" #include "esp_netif.h" #include "esp_netif_sntp.h" #include "esp_log.h" #include "esp_timer.h" #include "audio_sys.h" #include "audio_thread.h" #include "esp_peripherals.h" #include "periph_wifi.h" #include "periph_spiffs.h" #include "periph_sdcard.h" #include "audio_mem.h" #include "board.h" #include "volc_rtc.h" // #define ENABLE_TASK_MONITOR static char *TAG = "main"; #if defined(ENABLE_TASK_MONITOR) static void monitor_task(void *arg) { while (1) { audio_sys_get_real_time_stats(); AUDIO_MEM_SHOW(TAG); vTaskDelay(10000 / portTICK_RATE_MS); } } #endif void app_main() { ESP_ERROR_CHECK(nvs_flash_init()); ESP_ERROR_CHECK(esp_netif_init()); ESP_LOGI(TAG, "Initialize board peripherals"); esp_periph_config_t periph_cfg = DEFAULT_ESP_PERIPH_SET_CONFIG(); esp_periph_set_handle_t set = esp_periph_set_init(&periph_cfg); #if CONFIG_ENABLE_RECORDER_DEBUG // Initialize SD Card peripheral audio_board_sdcard_init(set, SD_MODE_1_LINE); #endif periph_spiffs_cfg_t spiffs_cfg = { .root = "/spiffs", .partition_label = "spiffs_data", .max_files = 5, .format_if_mount_failed = true}; esp_periph_handle_t spiffs_handle = periph_spiffs_init(&spiffs_cfg); esp_periph_start(set, spiffs_handle); // Wait until spiffs is mounted while (!periph_spiffs_is_mounted(spiffs_handle)) { vTaskDelay(500 / portTICK_PERIOD_MS); } periph_wifi_cfg_t wifi_cfg = { .wifi_config.sta.ssid = CONFIG_WIFI_SSID, .wifi_config.sta.password = CONFIG_WIFI_PASSWORD, }; esp_periph_handle_t wifi_handle = periph_wifi_init(&wifi_cfg); esp_periph_start(set, wifi_handle); periph_wifi_wait_for_connected(wifi_handle, portMAX_DELAY); esp_sntp_config_t config = ESP_NETIF_SNTP_DEFAULT_CONFIG("pool.ntp.org"); esp_netif_sntp_init(&config); // wait for time to be set int retry = 0; const int retry_count = 5; while (esp_netif_sntp_sync_wait(1000 / portTICK_PERIOD_MS) == ESP_ERR_TIMEOUT && ++retry < retry_count) { ESP_LOGI(TAG, "Waiting for system time to be set... (%d/%d)", retry, retry_count); } // Set timezone to China Standard Time time_t now = 0; struct tm timeinfo = { 0 }; setenv("TZ", "CST-8", 1); tzset(); localtime_r(&now, &timeinfo); audio_board_handle_t board_handle = audio_board_init(); audio_hal_ctrl_codec(board_handle->audio_hal, AUDIO_HAL_CODEC_MODE_BOTH, AUDIO_HAL_CTRL_START); audio_hal_set_volume(board_handle->audio_hal, 80); #if defined(ENABLE_TASK_MONITOR) audio_thread_create(NULL, "monitor_task", monitor_task, NULL, 5 * 1024, 13, true, 0); #endif // init byte rtc engine volc_rtc_init(); } 上述代码为什么在 #include "freertos/idf_additions.h" #include "nvs_flash.h" #include "esp_event.h" #include "esp_netif.h" #include "esp_netif_sntp.h" #include "esp_log.h" #include "esp_timer.h" #include "audio_sys.h" #include "audio_thread.h" #include "esp_peripherals.h" #include "periph_wifi.h" #include "periph_spiffs.h" #include "periph_sdcard.h" #include "audio_mem.h" #include "board.h" 的下面显示波浪线,显示无法找到源文件,该怎么解决
07-12
root@iZi7dk1ssj9d7tZ:/usr/local/nginx-1.24.0# ./configure --prefix=/usr/local/nginx checking for OS + Linux 6.8.0-78-generic x86_64 checking for C compiler ... found + using GNU C compiler + gcc version: 13.3.0 (Ubuntu 13.3.0-6ubuntu2~24.04) checking for gcc -pipe switch ... found checking for -Wl,-E switch ... found checking for gcc builtin atomic operations ... found checking for C99 variadic macros ... found checking for gcc variadic macros ... found checking for gcc builtin 64 bit byteswap ... found checking for unistd.h ... found checking for inttypes.h ... found checking for limits.h ... found checking for sys/filio.h ... not found checking for sys/param.h ... found checking for sys/mount.h ... found checking for sys/statvfs.h ... found checking for crypt.h ... found checking for Linux specific features checking for epoll ... found checking for EPOLLRDHUP ... found checking for EPOLLEXCLUSIVE ... found checking for eventfd() ... found checking for O_PATH ... found checking for sendfile() ... found checking for sendfile64() ... found checking for sys/prctl.h ... found checking for prctl(PR_SET_DUMPABLE) ... found checking for prctl(PR_SET_KEEPCAPS) ... found checking for capabilities ... found checking for crypt_r() ... found checking for sys/vfs.h ... found checking for UDP_SEGMENT ... found checking for nobody group ... not found checking for nogroup group ... found checking for poll() ... found checking for /dev/poll ... not found checking for kqueue ... not found checking for crypt() ... not found checking for crypt() in libcrypt ... found checking for F_READAHEAD ... not found checking for posix_fadvise() ... found checking for O_DIRECT ... found checking for F_NOCACHE ... not found checking for directio() ... not found checking for statfs() ... found checking for statvfs() ... found checking for dlopen() ... found checking for sched_yield() ... found checking for sched_setaffinity() ... found checking for SO_SETFIB ... not found checking for SO_REUSEPORT ... found checking for SO_ACCEPTFILTER ... not found checking for SO_BINDANY ... not found checking for IP_TRANSPARENT ... found checking for IP_BINDANY ... not found checking for IP_BIND_ADDRESS_NO_PORT ... found checking for IP_RECVDSTADDR ... not found checking for IP_SENDSRCADDR ... not found checking for IP_PKTINFO ... found checking for IPV6_RECVPKTINFO ... found checking for TCP_DEFER_ACCEPT ... found checking for TCP_KEEPIDLE ... found checking for TCP_FASTOPEN ... found checking for TCP_INFO ... found checking for accept4() ... found checking for int size ... 4 bytes checking for long size ... 8 bytes checking for long long size ... 8 bytes checking for void * size ... 8 bytes checking for uint32_t ... found checking for uint64_t ... found checking for sig_atomic_t ... found checking for sig_atomic_t size ... 4 bytes checking for socklen_t ... found checking for in_addr_t ... found checking for in_port_t ... found checking for rlim_t ... found checking for uintptr_t ... uintptr_t found checking for system byte ordering ... little endian checking for size_t size ... 8 bytes checking for off_t size ... 8 bytes checking for time_t size ... 8 bytes checking for AF_INET6 ... found checking for setproctitle() ... not found checking for pread() ... found checking for pwrite() ... found checking for pwritev() ... found checking for strerrordesc_np() ... found checking for localtime_r() ... found checking for clock_gettime(CLOCK_MONOTONIC) ... found checking for posix_memalign() ... found checking for memalign() ... found checking for mmap(MAP_ANON|MAP_SHARED) ... found checking for mmap("/dev/zero", MAP_SHARED) ... found checking for System V shared memory ... found checking for POSIX semaphores ... found checking for struct msghdr.msg_control ... found checking for ioctl(FIONBIO) ... found checking for ioctl(FIONREAD) ... found checking for struct tm.tm_gmtoff ... found checking for struct dirent.d_namlen ... not found checking for struct dirent.d_type ... found checking for sysconf(_SC_NPROCESSORS_ONLN) ... found checking for sysconf(_SC_LEVEL1_DCACHE_LINESIZE) ... found checking for openat(), fstatat() ... found checking for getaddrinfo() ... found checking for PCRE2 library ... not found checking for PCRE library ... found checking for PCRE JIT support ... found checking for zlib library ... found creating objs/Makefile Configuration summary + using system PCRE library + OpenSSL library is not used + using system zlib library nginx path prefix: "/usr/local/nginx" nginx binary file: "/usr/local/nginx/sbin/nginx" nginx modules path: "/usr/local/nginx/modules" nginx configuration prefix: "/usr/local/nginx/conf" nginx configuration file: "/usr/local/nginx/conf/nginx.conf" nginx pid file: "/usr/local/nginx/logs/nginx.pid" nginx error log file: "/usr/local/nginx/logs/error.log" nginx http access log file: "/usr/local/nginx/logs/access.log" nginx http client request body temporary files: "client_body_temp" nginx http proxy temporary files: "proxy_temp" nginx http fastcgi temporary files: "fastcgi_temp" nginx http uwsgi temporary files: "uwsgi_temp" nginx http scgi temporary files: "scgi_temp"
09-24
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值