| | 54 | |
|---|
| | 55 | |
|---|
| | 56 | /** |
|---|
| | 57 | * 指定の月の最初の曜日を調べます。 |
|---|
| | 58 | * |
|---|
| | 59 | * @param fullyear 西暦 |
|---|
| | 60 | * @param month 月 |
|---|
| | 61 | * @author michi at seyself.com |
|---|
| | 62 | */ |
|---|
| | 63 | public static function getFirstDay(fullyear,month) |
|---|
| | 64 | { |
|---|
| | 65 | var tmp = new Date(fullyear,month,1); |
|---|
| | 66 | return tmp.getDay(); |
|---|
| | 67 | } |
|---|
| | 68 | |
|---|
| | 69 | /** |
|---|
| | 70 | * うるう年かどうかを調べます |
|---|
| | 71 | * |
|---|
| | 72 | * @param fullyear 西暦 |
|---|
| | 73 | * @return うるう年の場合はtrueを返します。 |
|---|
| | 74 | * @author michi at seyself.com |
|---|
| | 75 | */ |
|---|
| | 76 | public static function isLeap( fullyear:uint ):Boolean |
|---|
| | 77 | { |
|---|
| | 78 | var flag = false; |
|---|
| | 79 | if(((fullyear%4==0) && (fullyear%100!=0)) || (fullyear%400==0)) flag = true; |
|---|
| | 80 | return flag; |
|---|
| | 81 | } |
|---|
| | 82 | |
|---|
| | 83 | /** |
|---|
| | 84 | * 西暦を和暦に変換します |
|---|
| | 85 | * 対応しているのは明治以降になります(1868年以降) |
|---|
| | 86 | * |
|---|
| | 87 | * @param fullyear 西暦 |
|---|
| | 88 | * @return 和暦(例:H20) |
|---|
| | 89 | * @author michi at seyself.com |
|---|
| | 90 | */ |
|---|
| | 91 | public static function convertJP( fullyear:uint ):String |
|---|
| | 92 | { |
|---|
| | 93 | var gengou = ["M", "T", "S", "H"]; |
|---|
| | 94 | var changeYear = [1868, 1912, 1926, 1989]; |
|---|
| | 95 | var str = "" , reki = 0; |
|---|
| | 96 | var len:uint = changeYear.length; |
|---|
| | 97 | for (var i:int = len - 1; i > 0; i--) { |
|---|
| | 98 | if (fullyear >= changeYear[i]) { |
|---|
| | 99 | str = gengou[i]; reki = fullyear - changeYear[i] + 1; |
|---|
| | 100 | break; |
|---|
| | 101 | } |
|---|
| | 102 | } |
|---|
| | 103 | if (str) { |
|---|
| | 104 | return str + reki; |
|---|
| | 105 | } |
|---|
| | 106 | return "" + fullyear; |
|---|
| | 107 | } |
|---|
| | 108 | |
|---|
| | 109 | /** |
|---|
| | 110 | * 曜日名を取得します |
|---|
| | 111 | * |
|---|
| | 112 | * @param index 曜日インデックス値 |
|---|
| | 113 | * @param type 取得する曜日名のタイプ(0から7まで) |
|---|
| | 114 | * @return 曜日名 |
|---|
| | 115 | * @author michi at seyself.com |
|---|
| | 116 | */ |
|---|
| | 117 | public static function getWeekName( index:uint , type:uint=0 ):String |
|---|
| | 118 | { |
|---|
| | 119 | var week:Array; |
|---|
| | 120 | if(type==0) week = ["SUNDAY","MONDAY","TUSEDAY","WEDNESDAY","THURSDAY","FRIDAY","SATURDAY"]; |
|---|
| | 121 | else if(type==1) week = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]; |
|---|
| | 122 | else if(type==2) week = ["sunday","monday","tuesday","wednesday","thursday","friday","saturday"]; |
|---|
| | 123 | else if(type==3) week = ["SUN","MON","TUE","WED","THU","FRI","SAT"]; |
|---|
| | 124 | else if(type==4) week = ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]; |
|---|
| | 125 | else if(type==5) week = ["sun","mon","tue","wed","thu","fri","sat"]; |
|---|
| | 126 | else if(type==6) week = ["日曜日","月曜日","火曜日","水曜日","木曜日","金曜日","土曜日"]; |
|---|
| | 127 | else if(type==7) week = ["日","月","火","水","木","金","土"]; |
|---|
| | 128 | else week = ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]; |
|---|
| | 129 | return week[index]; |
|---|
| | 130 | } |
|---|
| | 131 | |
|---|
| | 132 | /** |
|---|
| | 133 | * 月を示す文字列を返します |
|---|
| | 134 | * |
|---|
| | 135 | * @param index 月 |
|---|
| | 136 | * @param type 取得する月名のタイプ(0から7まで) |
|---|
| | 137 | * @return 月名 |
|---|
| | 138 | * @author michi at seyself.com |
|---|
| | 139 | */ |
|---|
| | 140 | public static function getMonthName( index:uint , type:uint=0 ):String |
|---|
| | 141 | { |
|---|
| | 142 | var month:Array; |
|---|
| | 143 | if(type==0) month = ["JANUARY","FEBRUARY","MARCH","APRIL","MAY","JUNE","JULY","AUGUST","SEPTEMBER","OCTOBER","NOVEMBER","DECEMBER"]; |
|---|
| | 144 | else if(type==1) month = ["January","February","March","April","May","June","July","August","September","October","November","December"]; |
|---|
| | 145 | else if(type==2) month = ["january","february","march","april","may","june","july","august","september","october","november","december"]; |
|---|
| | 146 | else if(type==3) month = ["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]; |
|---|
| | 147 | else if(type==4) month = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]; |
|---|
| | 148 | else if(type==5) month = ["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"]; |
|---|
| | 149 | else if(type==6) month = ["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"]; |
|---|
| | 150 | else if(type==7) month = ["睦月","如月","弥生","卯月","皐月","水無月","文月","葉月","長月","神無月","霜月","師走"]; |
|---|
| | 151 | else month = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]; |
|---|
| | 152 | return month[index]; |
|---|
| | 153 | } |
|---|
| | 154 | |
|---|
| | 155 | |
|---|