| 00317 01/02/09 20:23 | RE:00315 "getdate で取得した日付の一週 |
| 投稿者 : 大森鉄工所 | コメントを投稿する |
こんにちは。 プログラミング関係の仕事をされている方には初歩の初歩なのかも知れま せん。 でも、いざ無から作ろうと思うとちょっと大変。私が我流で作ったのはこ んな感じです。良かったら使ってください。 ( 何10万年も過去や未来の計算はできません。 0年は 紀元前 1年、-1年は 紀元前 2年です ) ;datetolinear と lineeartodate beginloop ; 動作check input "年月日 001231 or 2000/12/31", #date if( #date == "" or cancel ) exit datetolinear #date, ##datel if( search( #date, "/" ) == "" ) call datetolinear, #date else call datetolinear8, #date endif ##lind = value( #return ) message "script func:^I" + ##lind + "^Mdatetolinear:^I" + ##datel call lineartoweek, ##lind #week = #return call lineartodate, ##lind message #date + "^M" + #return + " " + #week endloop datetolinear8: ;リニア化 type 99/12/31 ##f = 1 goto datetolinear_p1 datetolinear10: ;リニア化 type 1999/12/31 ##f = 0 datetolinear_p1: #s = tohankaku( #1 ) ##i = 3 while( 0 < ##i ) ##i = ##i - 1 ##p[ ##i ] = value( #s ) #s = search( #s, "/" ) if( #s == "" ) #s = "1" else #s = part( #s, 1, 255 ) endif endwhile if( 0 < ##f ) if( 0 <= ##p[2] and ##p[2] < 100 ) ##p[2] = ( ##p[2] + 20 ) % 100 + 1980 endif endif call datetolinear_f, ##p[2], ##p[1], ##p[0] return #return datetolinear: ;リニア化 type 991231 call datetolinear_f, \ ( value( part( #1, 0, 2 ) ) + 20 ) % 100 + 1980, \ part( #1, 2, 2 ), part( #1, 4, 2 ) return #return datetolinear_f: ;年, 月, 日 1980/01/01からの経過日数に変換 ##b = value( #2 ) ##a = ( ##b + 17638463 ) / 12 - 1469872 ##b = - ##a * 12 + ##b + 9 ##a = ( ##b - 17 ) / 6 + value( #1 ) + ##a + 732800 return "" + ( \ ( ##b % 12 * 153 + 2 ) / 5 + ( ##a * 1461 / 4 ) \ - ( ##a / 100 ) + ( ##a / 400 ) \ + value( #3 ) - 268372825 \ ) lineartoweek: ;日付リニア値から曜日を求める return part( "日月火水木金土", ( value( #1 ) + 268372827 ) % 7 * 2, 2 ) lineartoweek_e: return part( "SunMonTueWedThuFriSat", ( value( #1 ) + 268372827 ) % 7 * 3, 3 ) lineartodate10: ;戻し type 1999/12/31 #rp = "lineartodate_p2" goto lineartodate_f lineartodate_p2: #s = "0" + ##c #s = "0" + ##b + "/" + part( #s, length( #s ) - 2, 2 ) #s = "" + ##a + "/" + part( #s, length( #s ) - 5, 5 ) if( 0 <= ##a and ##a < 1000 ) #s = "000" + #s #s = part( #s, length( #s ) - 10, 10 ) endif return #s lineartodate: ;戻し type 991231 #rp = "lineartodate_p1" goto lineartodate_f lineartodate_p1: #s = "0" + ( ( ##a * 100 + ##b ) * 100 + ##c ) return part( #s, length( #s ) - 6, 6 ) lineartodate_f: ;日付リニア値を一般形式に戻す ##c = value( #1 ) + 268372824 ; 723120+267649704= 268372824 ##a = ( ##c * 4 + 3 ) / 146097 ##c = - ##a * 146097 / 4 + ##c ##e = ( ##c * 4 + 3 ) / 1461 ##c = - ##e * 1461 / 4 + ##c ##b = ( ##c * 5 + 2 ) / 153 ##c = - ( ##b * 153 + 2 ) / 5 + 1 + ##c ##a = ##a * 100 + ##e + ( ##b / 10 ) - 732800 ##b = ( ##b + 2 ) % 12 + 1 goto #rp |
| 新規に投稿する |