tags:

views:

91

answers:

1

Hi,

I was trying to set the timezone of my system, and 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?

+3  A: 

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

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

Nikolai N Fetissov
...and for a single session / user, set the `TZ` environment variable.
caf
Thanks for your reply. Just to make sure I get it... I want to set the timezone for the whole system in C. So would I need to find some way to symlink /etc/localtime to the file under /usr/share/zoneinfo right? Using tzset() wouldn't work..Sorry, I'm really new to linux and don't have admin rights on my work system to try and mess with the system.
iman453
http://linux.die.net/man/2/symlink
Nikolai N Fetissov
Sweet, thanks..
iman453
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?
iman453
Ok, that looks real bad..I'll just edit my post
iman453