GadgetSeed  0.9.6
datetime.h ファイル

日付時刻 [詳解]

#include "timer.h"
datetime.h の依存先関係図:
被依存関係図:

[ソースコード]

データ構造

struct  st_datetime
 時刻構造体 [詳解]
 
struct  st_systime
 システム時間 [詳解]
 

マクロ定義

#define GSC_TIMEZONE_STR   "JST"
 $gsc タイムゾーンを示す文字列
 
#define GSC_DIFF_FROM_LOCAL_TIME_SEC   (9*60*60)
 $gsc UTCと日本時間(+9時間)との時差(秒)
 
#define DATE_STR_LEN   ((unsigned int)sizeof("YYYY/MM/DD WWW"))
 
#define TIME_STR_LEN   ((unsigned int)sizeof("HH/MM/SS"))
 
#define MSEC_STR_LEN   ((unsigned int)sizeof(".mmm"))
 
#define DATETIME_STR_LEN   (DATE_STR_LEN + 1 + TIME_STR_LEN)
 
#define DATEMTIME_STR_LEN   (DATE_STR_LEN + 1 + TIME_STR_LEN + 1 + MSEC_STR_LEN)
 

型定義

typedef long long int t_time
 

関数

int read_rtc_time (struct st_datetime *datetime)
 
void datetime_to_str (char *str, struct st_datetime *datetime)
 時間を日付時間文字列に変換する [詳解]
 
void datemtime_to_str (char *str, struct st_datetime *datetime)
 時間を日付ミリ秒時間文字列に変換する [詳解]
 
void date_to_str (char *str, struct st_datetime *datetime)
 時間を日付文字列に変換する [詳解]
 
void mtime_to_str (char *str, struct st_datetime *datetime)
 時間をミリ秒時間文字列に変換する [詳解]
 
void time_to_str (char *str, struct st_datetime *datetime)
 時間を時間文字列に変換する [詳解]
 
int set_rtc (struct st_datetime *datetime)
 
int init_time (char *devname)
 時計を初期する [詳解]
 
char date_to_dayofweek (short year, char month, char day)
 西暦年、月、日より曜日を求める [詳解]
 
int is_leap_year (int year)
 うるう年か調べる [詳解]
 
int num_of_day_in_month (int year, int month)
 うるう月か調べる [詳解]
 
void unixtime_to_datetime (struct st_datetime *datetime, struct st_systime *unixtime)
 UNIX時間より時刻を求める [詳解]
 
void systime_to_datetime (struct st_datetime *datetime, struct st_systime *stime)
 システム時間よりローカル時刻を求める [詳解]
 
t_time datetime_to_utc (struct st_datetime *datetime)
 ローカル西暦年月日、時間よりUTCを求める [詳解]
 
void datetime_to_systime (struct st_systime *systime, struct st_datetime *time)
 ローカル西暦年月日、時間よりシステム時間を求める [詳解]
 
void set_systime (struct st_systime *systime)
 UTC時刻からシステム時間を設定する [詳解]
 
t_time get_systime_sec (void)
 システム時間(秒)を取得する [詳解]
 
unsigned int fattime (void)
 FAT 現在実時間を取得する [詳解]
 
void get_systime (struct st_systime *systime)
 システム時間を取得する [詳解]
 
void register_sec_timer_func (timer_func func)
 時刻秒更新に同期した1秒周期処理を登録する [詳解]
 
void sync_systime_from_rtc (void)
 
void adjust_systime (void)
 
void sync_rtc_from_systime (void)
 

変数

struct st_systime system_time
 
struct st_systime l_system_time
 
timer_func sec_timer_func
 1秒間隔処理関数
 

詳解

日付時刻

日付
2015.09.19
2007.05.01
著者
Takashi SHUDO

datetime.h に定義があります。

関数詳解

◆ date_to_dayofweek()

char date_to_dayofweek ( short  year,
char  month,
char  day 
)

西暦年、月、日より曜日を求める

引数
[out]year西暦年
[out]month
[out]day
戻り値
曜日(0:日曜日、6:土曜日)

datetime.c594 行目に定義があります。

◆ date_to_str()

void date_to_str ( char *  str,
struct st_datetime time 
)

時間を日付文字列に変換する

引数
[out]str日付文字列ポインタ
[in]time時間

datetime.c390 行目に定義があります。

◆ datemtime_to_str()

void datemtime_to_str ( char *  str,
struct st_datetime time 
)

時間を日付ミリ秒時間文字列に変換する

引数
[out]str日付時間文字列ポインタ
[in]time時間

datetime.c444 行目に定義があります。

◆ datetime_to_str()

void datetime_to_str ( char *  str,
struct st_datetime time 
)

時間を日付時間文字列に変換する

引数
[out]str日付時間文字列ポインタ
[in]time時間

datetime.c431 行目に定義があります。

◆ datetime_to_systime()

void datetime_to_systime ( struct st_systime systime,
struct st_datetime datetime 
)

ローカル西暦年月日、時間よりシステム時間を求める

1970/01/01 00:00:00 が 0 になる

引数
[out]systimeシステム時間
[in]datetime西暦年月日、時間

datetime.c736 行目に定義があります。

◆ datetime_to_utc()

t_time datetime_to_utc ( struct st_datetime datetime)

ローカル西暦年月日、時間よりUTCを求める

UTC 1970/01/01 00:00:00 が 0 になる JST 1970/01/01 09:00:00 が 0 になる

引数
[in]datetime西暦年月日、時間
戻り値
UTC時間

datetime.c704 行目に定義があります。

◆ fattime()

unsigned int fattime ( void  )

FAT 現在実時間を取得する

戻り値
FAT 現在実時間

datetime.c775 行目に定義があります。

参照先 st_datetime::day, get_systime(), st_datetime::hour, st_datetime::min, st_datetime::month, st_datetime::sec, systime_to_datetime(), st_datetime::year.

呼び出し関係図:

◆ get_systime()

void get_systime ( struct st_systime systime)

システム時間を取得する

引数
[out]システム時間
戻り値
エラーコード

datetime.c802 行目に定義があります。

参照先 st_systime::sec, system_time, st_systime::usec.

参照元 fattime().

被呼び出し関係図:

◆ get_systime_sec()

t_time get_systime_sec ( void  )

システム時間(秒)を取得する

戻り値
現在UTC時刻

datetime.c765 行目に定義があります。

参照先 st_systime::sec, system_time.

◆ init_time()

int init_time ( char *  devname)

時計を初期する

時間をリアルタイムクロックより読み出し設定する

引数
[in]devnameRTCデバイス名

リアルタイムクロックが無いシステムでは"0"を設定する

戻り値
!=0:エラー

datetime.c517 行目に定義があります。

◆ is_leap_year()

int is_leap_year ( int  year)

うるう年か調べる

引数
[in]year西暦年
戻り値
0:うるう年ではない、1:うるう年

datetime.c613 行目に定義があります。

参照元 num_of_day_in_month().

被呼び出し関係図:

◆ mtime_to_str()

void mtime_to_str ( char *  str,
struct st_datetime time 
)

時間をミリ秒時間文字列に変換する

引数
[out]str時間文字列ポインタ
[in]time時間

datetime.c419 行目に定義があります。

◆ num_of_day_in_month()

int num_of_day_in_month ( int  year,
int  month 
)

うるう月か調べる

引数
[in]year西暦年
[in]month
戻り値
日数

datetime.c632 行目に定義があります。

参照先 is_leap_year().

呼び出し関係図:

◆ register_sec_timer_func()

void register_sec_timer_func ( timer_func  func)

時刻秒更新に同期した1秒周期処理を登録する

引数
[in]func1秒周期処理関数

datetime.c820 行目に定義があります。

参照先 sec_timer_func.

◆ set_systime()

void set_systime ( struct st_systime systime)

UTC時刻からシステム時間を設定する

引数
[in]systimeUTC時刻

datetime.c747 行目に定義があります。

参照先 st_systime::sec, system_time, st_systime::usec.

◆ systime_to_datetime()

void systime_to_datetime ( struct st_datetime datetime,
struct st_systime stime 
)

システム時間よりローカル時刻を求める

引数
[out]datetime時刻(ローカル)
[in]timeシステム時間

datetime.c684 行目に定義があります。

参照元 fattime().

被呼び出し関係図:

◆ time_to_str()

void time_to_str ( char *  str,
struct st_datetime time 
)

時間を時間文字列に変換する

引数
[out]str時間文字列ポインタ
[in]time時間

datetime.c405 行目に定義があります。

◆ unixtime_to_datetime()

void unixtime_to_datetime ( struct st_datetime datetime,
struct st_systime unixtime 
)

UNIX時間より時刻を求める

引数
[out]datetime時刻
[in]unixtimeUNIX時間

datetime.c658 行目に定義があります。

変数詳解

◆ system_time

struct st_systime system_time

システム時間(UNIX時間、UTC) 1970/01/01 00:00:00 からの1秒カウン タ(2038年問題非対応)

datetime.c129 行目に定義があります。

参照元 get_systime(), get_systime_sec(), set_systime().