로컬 타임 구하는 코드인데 HHL 에서 테스트하는데.. 문제가 좀

beta의 이미지

ntp 을 이용해서 값을 가져온후 로컬에서 변환후 사용해서 할 일이 있어서 아래와 같은 과정이 필요합니다.

하드햇 리눅스의 경우 이와 같은 코드가 정확한 값을 도출해 내지 못합니다.
일반적인 다른 리눅스들은 문제 없는거 같습니다.

tm_hour 만 잘못된 값을 가져오는게 정말 이해가 안가네요. 거기만 실수 했을리도 없고.. --; 다 잘못 읽어오면 몰라도.. --;

HHL2.0 이나 다른 시스템에서 테스트좀 해 주실수 있으세요?

Quote:
test# ./ppc_test_time
correct value -> 2003-07-26 10:42:47
tm_sec -> 47
tm_min -> 42
tm_hour -> 1
tm_mday -> 26
tm_mon -> 6
tm_year -> 103
tm_wday -> 6
tm_yday -> 206
tm_isdst-> 0

2003-07-26 01:42:47

Quote:
./x86_test_time
correct value -> 2003-07-26 10:42:47
tm_sec -> 47
tm_min -> 42
tm_hour -> 10
tm_mday -> 26
tm_mon -> 6
tm_year -> 103
tm_wday -> 6
tm_yday -> 206
tm_isdst-> 0
2003-07-26 10:42:47

Quote:
#include <stdio.h>
#include <time.h>

int main( void )
{
char tm_buff0[16] = {'\0',} ;
char tm_buff1[16] = {'\0',} ;

time_t time_t_time = 0x3f21dc97;

struct tm tm ;
struct tm *p_tm = &tm ;

localtime_r( & time_t_time, &tm ) ;

fprintf(stderr, "correct value -> 2003-07-26 10:42:47 \n\r");

fprintf(stderr, "tm_sec -> %d\n", p_tm->tm_sec ) ;
fprintf(stderr, "tm_min -> %d\n", p_tm->tm_min ) ;
fprintf(stderr, "tm_hour -> %d\n", p_tm->tm_hour) ;
fprintf(stderr, "tm_mday -> %d\n", p_tm->tm_mday) ;
fprintf(stderr, "tm_mon -> %d\n", p_tm->tm_mon ) ;
fprintf(stderr, "tm_year -> %d\n", p_tm->tm_year) ;
fprintf(stderr, "tm_wday -> %d\n", p_tm->tm_wday) ;
fprintf(stderr, "tm_yday -> %d\n", p_tm->tm_yday) ;
fprintf(stderr, "tm_isdst-> %d\n", p_tm->tm_isdst) ;

sprintf(tm_buff0, "%d-%02d-%02d", p_tm->tm_year+1900, p_tm->tm_mon+1, p_tm->tm_mday);
sprintf(tm_buff1, "%02d:%02d:%02d", p_tm->tm_hour, p_tm->tm_min, p_tm->tm_sec ) ;

fprintf(stderr, "%s %s\n\r\n\r", tm_buff0, tm_buff1);

exit(0) ;
}

익명 사용자의 이미지

혹시 PPC에서 time zone설정이 잘못된거 아닌가요?
KST가 아닌 UTC로 되어 있는듯 한데...

또는 "UTC를 RTC로" 하는 옵션을 주고 배포판을 설치하신게 아닌지...

정확하게 9시간 차이가 나는거 보니 거의 확실한듯...

beta의 이미지

감사합니다. 님의 조언으로 해결되었습니다.

발 담갔다. 이제 익숙해 지는길만이..

antz의 이미지

minzkn wrote:
혹시 PPC에서 time zone설정이 잘못된거 아닌가요?
KST가 아닌 UTC로 되어 있는듯 한데...

또는 "UTC를 RTC로" 하는 옵션을 주고 배포판을 설치하신게 아닌지...

정확하게 9시간 차이가 나는거 보니 거의 확실한듯...

환경변수하고 상관이 없나요???

Quote:
export LC_TIME="ko"
또는
Quote:
export LC_TIME="KST"

프로그램 코드안에,

setlocale(LC_TIME,"KST"); 를 추가했는데도...

UTC 시간이 나오네요. :?:

KST 시간을 나오게 하는 방법이 없을까요???

beta의 이미지

어떤 프로그램으로 확인하고 계신지요?

1. /usr/share/zoneinfo/ROK 를 /etc/localtime 으로 링크한다.
또는
2. 환경변수 TZ=ROK or TZ=KST-9 로 셋트한다
또는
3. 이래도 안된다면 strace 같은 툴로 어떤 파일을 참조할려는지 확인해 보십시요.

mollla wrote:
minzkn wrote:
혹시 PPC에서 time zone설정이 잘못된거 아닌가요?
KST가 아닌 UTC로 되어 있는듯 한데...

또는 "UTC를 RTC로" 하는 옵션을 주고 배포판을 설치하신게 아닌지...

정확하게 9시간 차이가 나는거 보니 거의 확실한듯...

환경변수하고 상관이 없나요???

Quote:
export LC_TIME="ko"
또는
Quote:
export LC_TIME="KST"

프로그램 코드안에,

setlocale(LC_TIME,"KST"); 를 추가했는데도...

UTC 시간이 나오네요. :?:

KST 시간을 나오게 하는 방법이 없을까요???

발 담갔다. 이제 익숙해 지는길만이..

antz의 이미지

beta wrote:
어떤 프로그램으로 확인하고 계신지요?

아~ strace 로 알았습니다.

데몬 프로그램을 하고 있는데.

chroot로 인해 /etc/localtime을 읽지 못해서 UTC time으로 바뀌었군요.

혹시 chroot를 살리면서, 시간을 KST시간으로 하는 방법이 있을까요?

chroot의 디렉토리에 /etc/localtime을 만들면, KST시간이 잘나오는군요.

감사합니다.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.