开发者

How to specify timezone in linux using C

开发者 https://www.devze.com 2023-01-10 14:41 出处:网络
I was trying to set the timezone of my system, a开发者_StackOverflownd was trying to use settimeofday(), which takes a timezone struct as an argument, but just read that that struct is now obsolete (h

I was trying to set the timezone of my system, a开发者_StackOverflownd was trying to use settimeofday(), which takes a timezone struct as an argument, but just read that that struct is now obsolete (http://linux.about.com/library/cmd/blcmdl2_settimeofday.htm) How could I go about doing this?

Thanks in advance.

EDIT: Ugh, I feel really stupid.

I created a link.c and compiled it:

#include <stdio.h>

void main()
{
    printf("This is the link \n");
}

Created a target.c, and compiled it:

#include <stdio.h>

void main()
{
    printf("This is the target \n");
}

and then tried the symlink function in a test program:

#include <unistd.h>

void main()
{
    int garbage = symlink("/home/imandhan/pythonTests/link", "/home/imandhan/pythonTests/target");
    printf(garbage);
}

This gives me a segmentation fault for some reason. Am I doing something wrong?


See tzset(3) for setting timezone for an application.

For the whole system - symlink /etc/localtime to appropriate file under /usr/share/zoneinfo/.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号