예제 #1
0
Date::Date(time_t t)
{
	struct tm tm;
	safe_localtime(&tm, t);

	year_ = tm.tm_year + 1900;
	month_ = tm.tm_mon + 1;
	day_ = tm.tm_mday;
}
예제 #2
0
Time::Time(time_t t)
{
	struct tm tm;
	safe_localtime(&tm, t);

	hour_ = tm.tm_hour;
	minute_ = tm.tm_min;
	second_ = tm.tm_sec;
}
예제 #3
0
Time::operator time_t() const
{
	struct tm tm;
	safe_localtime(&tm, time(0));

	tm.tm_sec = second_;
	tm.tm_min = minute_;
	tm.tm_hour = hour_;
	tm.tm_isdst = -1;

	return mktime(&tm);
}
예제 #4
0
Date::operator time_t() const
{
	struct tm tm;
	safe_localtime(&tm, time(0));

	tm.tm_mday = day_;
	tm.tm_mon = month_ - 1;
	tm.tm_year = year_ - 1900;
	tm.tm_isdst = -1;

	return mktime(&tm);
}
예제 #5
0
DateTime::DateTime(time_t t)
{
	struct tm tm;
	safe_localtime(&tm, t);

	year_ = tm.tm_year + 1900;
	month_ = tm.tm_mon + 1;
	day_ = tm.tm_mday;
	hour_ = tm.tm_hour;
	minute_ = tm.tm_min;
	second_ = tm.tm_sec;

	now_ = false;
}
예제 #6
0
파일: sflcons.c 프로젝트: evoskuil/gsl
static char *
time_str (void)
{
    static char
        formatted_time [9];
    time_t
        time_secs;
    struct tm
        *time_struct;

    time_secs   = time (NULL);
    time_struct = safe_localtime (&time_secs);

    snprintf (formatted_time, sizeof (formatted_time),
                              "%02d:%02d:%02d",
                              time_struct-> tm_hour,
                              time_struct-> tm_min,
                              time_struct-> tm_sec);
    return (formatted_time);
}
예제 #7
0
파일: sflcons.c 프로젝트: evoskuil/gsl
static char *
date_str (void)
{
    static char
        formatted_date [11];
    time_t
        time_secs;
    struct tm
        *time_struct;

    time_secs   = time (NULL);
    time_struct = safe_localtime (&time_secs);

    snprintf (formatted_date, sizeof (formatted_date),
                              "%4d/%02d/%02d",
                              time_struct-> tm_year + 1900,
                              time_struct-> tm_mon  + 1,
                              time_struct-> tm_mday);

    return (formatted_date);
}
예제 #8
0
파일: sfltron.c 프로젝트: INNOAUS/gsl
static void
print_time_str (FILE *out)
{
    time_t
        time_secs;
    struct tm
        *time_struct;

    ASSERT (out);                 /*  Expect handle for output, fail nicely  */
    if (!out)
        return;

    time_secs   = time (NULL);
    time_struct = safe_localtime (&time_secs);

    fprintf (out, "%2d/%02d/%02d %2d:%02d:%02d",
                  time_struct-> tm_year + 1900,
                  time_struct-> tm_mon + 1,
                  time_struct-> tm_mday,
                  time_struct-> tm_hour,
                  time_struct-> tm_min,
                  time_struct-> tm_sec);
}