opreate_calendar.c

カレンダー操作プログラム [詳細]

#include <stdio.h>
#include <string.h>
#include <time.h>
#include "number_set.h"

関数

int judge_month (int year, int month, char holiday_name[HOLY_MAX][HOLY_NAME], int holiday_days[HOLY_MAX])
void month_print_calendar (int year, int month)
void month_print_calendar_today (int year, int month, int day)
void input_year_cal (int year)
void input_fiscal_cal (int year)
DAY_DATE get_today ()
void row_calendar_main (int cal_buf[COL_CAL][WEEK_ROW][WEEK_COL], int week_max, int holiday_num[COL_CAL][HOLY_MAX])
void row_calendar_main_today (int cal_buf[COL_CAL][WEEK_ROW][WEEK_COL], int week_max, int holiday_num[COL_CAL][HOLY_MAX], int month, int day, int arr_month[COL_CAL])
void input_ym_three (int year, int month)
void input_ym_three_today (int year, int month, DAY_DATE today)
void print_calendar_three (int year[COL_CAL], int month[COL_CAL])
void make_array (int arr_year[COL_CAL], int arr_month[COL_CAL], int year, int month)
void row_holiday (char holiday_name[COL_CAL][HOLY_MAX][HOLY_NAME], int hol_max)
void this_month_cal ()
void next_month_cal ()
void before_month_cal ()
void this_year_cal ()
void next_year_cal ()
void before_year_cal ()
void this_fiscal_cal ()
void next_fiscal_cal ()
void before_fiscal_cal ()
void this_three_month ()

説明

カレンダー操作プログラム

作者:
y_okamon
バージョン:
1.1(2008.10.14)
新ファイル作成の意図
ファイルoutput_calendarから、カレンダー操作部分をこのファイルに移行
コマンドオプション追加においての関数の設計
(1) 次月を表示する関数next_month_cal、前月を表示する関数before_month_calを設計
(2) 次年を表示する関数next_year_cal、前年を表示する関数before_year_calを設計
(3) 次年度を表示する関数next_fiscal_cal、前年を表示する関数before_year_calを設計

日付取得用構造体DAY_DATEを設定したときの関数の仕様変更
(1) システム上の日付を取得する関数get_todayを設計、返り値はDAY_DATE型の変数となる
(2) (1)から、next、this、before系の関数の行数を削減することに成功

関数input_ym_calの削除について
この関数は、各関数から年月を引数として受け取って、month_print_calendarを参照していた。 しかし、この関数を参照しないで、各関数がmonth_print_calendarを直接参照しても結果が変わらないと判明 よって、この関数は不要となったので削除

カレンダーを横に3個表示するときの仕様変更
(1) 関数input_ym_three内3次元の文字列配列から整数型配列に変更
(2) 関数input_ym_three内3ヶ月分の年と月を入れる配列を設定
(3) 関数make_calendarのカレンダー設定部分を関数make_three_calendarに変更
(4) 配列に3ヶ月分のデータを入れることで、ループで関数make_holidayを処理(関数make_calendarの祝日部分を関数make_holidayに変更)

関数val_updateの削除について
最初はループカウンタ、最大祝日日数、最大週数の更新を関数input_ym_threeに入れると長くなってしまうために設定した。 しかし、最大祝日日数は関数make_holidayで、最大週数はmake_calendarで処理させるようにした それにより、ループカウンタは関数input_ym_threeで処理すればよいので、関数val_updateを削除

年間および年度カレンダー表示処理
年間および年度間カレンダーの表示はprint_calendar_yearで行っていたが、仕様を変更した関数input_ym_threeを4回呼び出して、 実験を行ってみたら同じような結果が得られた。そのため関数print_calendar_yearは不要となったので削除


関数

void before_fiscal_cal (  ) 

機能
前年度のカレンダーを表示する

処理詳細
(1) システム上の年と月を取得する
(2) 年をマイナス1する。 (3) 取得した月が1月〜3月の間であったら、年を1年マイナス
(4) 取得した年をinput_year_cal関数で処理

被参照自作関数
ファイルghcal.c内 関数argcheck

参照自作関数
ファイルopreate_calendar.c内 関数get_today<br? ファイルopreate_calendar.c内 関数input_fiscal_cal

void before_month_cal (  ) 

機能
先月のカレンダーを表示する

処理詳細
(1) システム上の年月を取得する。
(2) 取得した年月を関数month_print_calendarで処理

被参照自作関数
ファイルghcal.c内 関数argcheck

参照自作関数
ファイルopreate_calendar.c内 関数month_print_calendar
ファイルopreate_calendar.c内 関数get_today

void before_year_cal (  ) 

機能
昨年の年間カレンダーを表示する

処理詳細
(1) システム上の年を取得する
(2) 取得した年から1を引いた年をinput_year_cal関数で処理

被参照自作関数
ファイルhcal.c内 関数argcheck

参照自作関数
ファイルopreate_calendar.c内 関数input_year_cal
ファイルopreate_calendar.c内 関数get_today

DAY_DATE get_today (  ) 

機能
システム上の年月日を取得する

戻り値:
today 本日の日付が入った構造体型変数

被参照自作関数
ファイルopreate_calendar.c内 関数this_month_cal
ファイルopreate_calendar.c内 関数next_month_cal
ファイルopreate_calendar.c内 関数before_month_cal
ファイルopreate_calendar.c内 関数this_year_cal
ファイルopreate_calendar.c内 関数next_year_cal
ファイルopreate_calendar.c内 関数before_year_cal
ファイルopreate_calendar.c内 関数this_fiscal_cal
ファイルopreate_calendar.c内 関数next_fiscal_cal
ファイルopreate_calendar.c内 関数before_fiscal_cal
ファイルopreate_calendar.c内 関数this_three_month
ファイルopreate_calendar_gengoh.c内 関数this_month_cal_gengoh
ファイルopreate_calendar_gengoh.c内 関数next_month_cal_gengoh
ファイルopreate_calendar_gengoh.c内 関数before_month_cal_gengoh
ファイルopreate_calendar_gengoh.c内 関数this_year_cal_gengoh
ファイルopreate_calendar_gengoh.c内 関数next_year_cal_gengoh
ファイルopreate_calendar_gengoh.c内 関数before_year_cal_gengoh
ファイルopreate_calendar_gengoh.c内 関数this_fiscal_cal_gengoh
ファイルopreate_calendar_gengoh.c内 関数next_fiscal_cal_gengoh
ファイルopreate_calendar_gengoh.c内 関数before_year_cal_gengoh

参照自作関数
なし

void input_fiscal_cal ( int  year  ) 

機能
入力された年の年度カレンダーを表示させる

引数:
year 

被参照自作関数
ファイルghcal.c内 関数argcheck
ファイルopreate_calendar.c内 関数next_fiscal_cal
ファイルopreate_calendar.c内 関数before_fiscal_cal

参照自作関数
ファイルopreate_calendar.c内 関数input_ym_three

void input_year_cal ( int  year  ) 

機能
入力された年の年間カレンダーを表示させる

処理詳細
横に3ヶ月分のカレンダーを表示する。

引数:
year 

被参照自作関数
ファイルghcal.c内 関数argcheck
ファイルopreate_calendar.c内 関数next_year_cal
ファイルopreate_calendar.c内 関数before_year_cal

参照自作関数
ファイルopreate_calendar.c内 関数input_ym_three

void input_ym_three ( int  year,
int  month 
)

機能 先月、今月、来月の3ヶ月カレンダーを表示する

処理詳細 (1) 入力/システムから獲得した月によって以下の処理をする。
(1.1) 月が1月なら、前年の12月からシステム上の年の2月までのカレンダーを作る。
(1.2) 月が12月なら、11月から翌年の1月までのカレンダーを作る。
(1.3) それ以外の月なら、前の月から翌月までのカレンダーを作る。
(2) 3ヶ月分のカレンダーが作成したら、横にカレンダーを表示する

引数:
year 
month 

被参照自作関数
ファイルghcal.c内 関数argcheck
ファイルoutput_calendar内 関数input_year_cal
ファイルoutput_calendar内 関数input_fiscal_cal

参照自作関数
ファイルopreate_calendar.c内 関数make_array
ファイルcalendar_main.c内 関数make_three_calendar
ファイルcalendar_main.c内 関数make_holiday
ファイルoutput_calendar.c内 関数print_calendar_three
ファイルoutput_calendar.c内 関数row_calendar_main
ファイルoutput_calendar.c内 関数row_holiday

void input_ym_three_today ( int  year,
int  month,
DAY_DATE  today 
)

機能 先月、今月、来月の3ヶ月カレンダーを表示する

処理詳細 (1) 入力/システムから獲得した月によって以下の処理をする。
(1.1) 月が1月なら、前年の12月からシステム上の年の2月までのカレンダーを作る。
(1.2) 月が12月なら、11月から翌年の1月までのカレンダーを作る。
(1.3) それ以外の月なら、前の月から翌月までのカレンダーを作る。
(2) 3ヶ月分のカレンダーが作成したら、横にカレンダーを表示する

引数:
year 
month 
today システム上の日付

被参照自作関数
ファイルghcal.c内 関数argcheck
ファイルopreate_calendar内 関数this_three_month

参照自作関数
ファイルopreate_calendar.c内 関数make_array
ファイルcalendar_main.c内 関数make_three_calendar
ファイルcalendar_main.c内 関数make_holiday
ファイルoutput_calendar.c内 関数print_calendar_three
ファイルoutput_calendar.c内 関数row_calendar_main
ファイルoutput_calendar.c内 関数row_holiday

int judge_month ( int  year,
int  month,
char  holiday_name[HOLY_MAX][HOLY_NAME],
int  holiday_num[HOLY_MAX] 
)

機能
入力された月による祝日有無を判定する

引数:
year 
month 
holiday_name[][] 祝日名代入する配列
holiday_num[][] 祝日日付代入配列(Ver1.1)
戻り値:
m_holidays 月ごとの祝日日数を返す

被参照自作関数
ファイルcalendar_main.c内 関数make_calendar
ファイルoutput_calendar.c内 関数month_print_calendar
ファイルoutput_calendar.c内 関数month_print_calendar_today

参照自作関数
ファイルinsert_holidays.c内 関数Jan_holiday
ファイルinsert_holidays.c内 関数Feb_holiday
ファイルinsert_holidays.c内 関数Mar_holiday
ファイルinsert_holidays.c内 関数Api_holiday
ファイルinsert_holidays.c内 関数May_holiday
ファイルinsert_holidays.c内 関数Jul_holiday
ファイルinsert_holidays.c内 関数Sep_holiday
ファイルinsert_holidays.c内 関数Oct_holiday
ファイルinsert_holidays.c内 関数Nov_holiday
ファイルinsert_holidays.c内 関数Dec_holiday

void make_array ( int  arr_year[COL_CAL],
int  arr_month[COL_CAL],
int  year,
int  month 
)

機能
配列にデータを入れる

引数:
arr_year[] 3ヶ月分の年
arr_month[] 3ヶ月分の月
year 基準年
month 基準月

被参照自作関数
ファイルopreate_calendar内 関数input_ym_three
ファイルopreate_calendar内 関数input_ym_three_today

参照自作関数
なし

void month_print_calendar ( int  year,
int  month 
)

機能
year年month月のカレンダーを祝日とともに表示する

処理詳細 
(1) year年month月の初日の曜日を算出
(2) year年month月の月日数を取得
(3) 初日から月末までのカレンダーを表示
(3.1) 日曜日なら赤で表示
(3.2) 土曜日なら青で表示
(3.3) それ以外の曜日は黒で表示
(4) 祝日名を表示する

引数:
year 
month 

被参照自作関数
ファイルopreate_calendar.c内 関数next_month_cal
ファイルopreate_calendar.c内 関数before_month_cal
ファイルghcal.c内 関数argcheck

参照自作関数
ファイルcalendar_main.c内 関数day_of_week
ファイルcalendar_main.c内 関数month_days
ファイルinsert_holidays.c内 関数judge_month

void month_print_calendar_today ( int  year,
int  month,
int  day 
)

機能
year年month月のカレンダーを祝日とともに表示し、システム上の日付の日を白抜きにする

処理詳細 
(1) year年month月の初日の曜日を算出
(2) year年month月の月日数を取得
(3) 初日から月末までのカレンダーを表示
(3.1) 日曜日なら赤で表示
(3.2) 土曜日なら青で表示
(3.3) それ以外の曜日は黒で表示
(3.4) システム上の日付なら文字色と背景色を反転
(4) 祝日名を表示する

引数:
year 
month 
day 

被参照自作関数
ファイルopreate_calendar.c内 関数this_month_cal

参照自作関数
ファイルcalendar_main.c内 関数day_of_week
ファイルcalendar_main.c内 関数month_days

void next_fiscal_cal (  ) 

機能
翌年度のカレンダーを表示する

処理詳細
(1) システム上の年と月を取得する
(2) 年をプラス1する。
(3) 取得した月が1月〜3月の間であったら、年を1年マイナス
(4) 取得した年をinput_year_cal関数で処理

被参照自作関数
ファイルghcal.c内 関数argcheck

参照自作関数
ファイルopreate_calendar.c内 関数input_fiscal_cal
ファイルopreate_calendar.c内 関数get_today

void next_month_cal (  ) 

機能
来月のカレンダーを表示する

処理詳細
(1) システム上の年月を取得する。
(2) 取得した年月を関数month_print_calendarで処理

被参照自作関数
ファイルghcal.c内 関数argcheck

参照自作関数
ファイルopreate_calendar.c内 関数month_print_calendar
ファイルopreate_calendar.c内 関数get_today

void next_year_cal (  ) 

機能
翌年の年間カレンダーを表示する

処理詳細
(1) システム上の年を取得する
(2) 取得した年+1をinput_year_cal関数で処理

被参照自作関数
ファイルghcal.c内 関数argcheck

参照自作関数
ファイルopreate_calendar.c内 関数input_year_cal
ファイルopreate_calendar.c内 関数get_today

void print_calendar_three ( int  year[COL_CAL],
int  month[COL_CAL] 
)

機能 指定された3ヶ月分の年と月を表示する

処理詳細
(1) 指定された3ヶ月分の年と月をバッファに入れる
(2) バッファを横に表示する

引数:
year[] 
month[] 

被参照自作関数
ファイルopreate_calendar.c 関数input_ym_three
ファイルorpeate_calendar.c 関数input_ym_three_today

参照自作関数
なし

void row_calendar_main ( int  cal_buf[COL_CAL][WEEK_ROW][WEEK_COL],
int  week_max,
int  holiday_num[COL_CAL][HOLY_MAX] 
)

機能
カレンダーを横に表示させる

処理詳細
(1) 曜日を表示
(2) 日付を曜日ごと、祝日ごとに色分けする

引数:
cal_buf[][][] カレンダーバッファ
week_max 最大週数
holiday_num[][] 日付代入配列

被参照自作関数
ファイルopreate_calendar.c内 関数input_ym_three
ファイルopreate_calendar.c内 関数input_ym_three_gengoh
ファイルopreate_calendar_gengoh.c内 関数input_1989_1to3
ファイルopreate_calendar_gengoh.c内 関数input_1989_three

参照自作関数
なし

void row_calendar_main_today ( int  cal_buf[COL_CAL][WEEK_ROW][WEEK_COL],
int  week_max,
int  holiday_num[COL_CAL][HOLY_MAX],
int  month,
int  day,
int  arr_month[COL_CAL] 
)

機能
カレンダーを横に表示させる

処理詳細
(1) 曜日を表示
(2) 日付を曜日ごと、祝日ごとに色分けする
(3) システム上の日付を文字色と背景色と反転
(4) 祝日を表示する

引数:
cal_buf[][][] カレンダーバッファ
week_max 最大週数
holiday_num[][] 日付代入配列
month システム上の月
day システム上の年
arr_month 3ヶ月分の月

被参照自作関数
ファイルorpeate_calendar.c内 関数input_ym_three_today
ファイルopreate_calendar_gengoh.c内 関数input_ym_three_today_gengoh

参照自作関数
なし

void row_holiday ( char  holiday_name[COL_CAL][HOLY_MAX][HOLY_NAME],
int  hol_max 
)

機能
3ヶ月分の祝日を横に表示させる

引数:
holiday_name[][][] 祝日
hol_max 最大祝日日数

被参照自作関数
ファイルopreate_calendar.c内 関数input_ym_three
ファイルopreate_calendar.c内 関数input_ym_three_today

参照自作関数
なし

void this_fiscal_cal (  ) 

機能
今年度のカレンダーを表示する

処理詳細
(1) システム上の年と月を取得する
(2) 取得した月が1月〜3月の間であったら、年を1年マイナス
(3) 取得した年をinput_year_cal関数で処理

被参照自作関数
ファイルghcal.c内 関数argcheck

参照自作関数
ファイルopreate_calendar.c内 関数input_ym_three_today
ファイルopreate_calendar.c内 関数input_ym_three
ファイルopreate_calendar.c内 関数get_today

void this_month_cal (  ) 

機能
今月のカレンダーを表示する

処理詳細
(1) システム上の年月を取得する。
(2) 取得した年月を関数month_print_calendar_gengohで処理

被参照自作関数
ファイルghcal.c内 関数argcheck

参照自作関数
ファイルopreate_calendar.c内 関数month_print_calendar_today
ファイルopreate_calendar.c内 関数get_today

void this_three_month (  ) 

機能
前月、今月、来月の3ヶ月を表示する

処理詳細
(1) システム上の年月を取得する
(2) 取得した年をinput_ym_three関数で処理

被参照自作関数
ファイルghcal.c内 関数argcheck

参照自作関数
ファイルopeate_calendar.c内 関数input_ym_three_today

void this_year_cal (  ) 

機能
今年の年間カレンダーを表示する

処理詳細
(1) システム上の年を取得する
(2) 取得した年をinput_year_cal関数で処理

被参照自作関数
ファイルghcal.c内 関数argcheck

参照自作関数
ファイルopreate_calendar.c内 関数input_ym_three_today
ファイルopreate_calendar.c内 関数input_ym_three
ファイルopreate_calendar.c内 関数get_today


13 Aug 2011に生成されました。  doxygen 1.6.1