1 / 1
"FillZero"으로 검색하여,
3 건의 기사가 검색 되었습니다.
-
2014-05-08랜덤키를 만들어야 하는 경우에 이용가능하다.랜덤으로 만들어진 값을 숫자(0~9)와 알파벳으로 표현하는 36진수로 변환 하여 랜덤키를 만듭니다.<%response.write KeyGen32()&".txt"function KeyGen32()dim iRnd, Responsedim cRnd, iRandomizecRnd = ""for i = 1 to 8iRnd = Int(( 999999 - 1 + 1) * Rnd + 1) '=== 6 digitscRnd = cRnd & Dec6to36( FillZero(iRnd,6) )nextKeyGen32 = cRndend functionfunction Dec6to36(num)dim d1,d2,d3,d4,r1,r2d1 = Int( num / 46656 )r1 = ( num mod 46656 )d2 = Int( r1 / 1296 )r2 = ( r1 mod 1296 )d3 = Int( r2 / 36 )d4 = ( r2 mod 36 )Dec6to36 = Convert10to36(d1) & Convert10to36(d2) & Convert10to36(d3) & Convert10to36(d4)end function'== 10진수를 36진수로 변환function Convert10to36( i )if ( i < 10 ) thenConvert10to36 = ielseConvert10to36 = chr(55+i)end ifend functionfunction FillZero( cString, iLength )FillZero = FillString( cString, iLength, "0" )end functionfunction FillString( cString, iLength, cFillString )if( iLength >Len(cString) ) thenFillString = ( String( iLength -Len( cString ), cFillString ) & cString )elseFillString = cStringend ifend function%>
-
2014-05-01그 동안 만들어 사용하던 날짜,시간 관련 함수들을 모아 봤다.ASP에선 날짜/시간을 출력하는 경우 시스템의 날짜형식으로 출력이 된다.적합한 모양으로 바꾸어 출력 되도록 하는것들이 대부분 함수들이다.모아보니 함수들이 많은것 같은데 필요할 때마다 추가한것이라 한번씩은 용도가 있었던것이라 참고 하시거나 사용안할듯 한것들은 제거 하여 재구성하여 사용 하길 추천 한다.GetFullDateTimeH(), GetFullDateH(): 구분자를 "-"로 출력 한다. ** in-line query 로 DB에 저장하는 경우 이 형식으로 날짜를 표현해야 한다.GetFullDateTimeON() : 날짜/시간의 숫자 값만 출력한다. ** 임시파일의 파일명 생성시 4~6자리의 랜덤 값과 사용하면 중복을 쉽게 피할 수 있다.GetMonthLastDate(): 해당월의 마지막일자를 구한다. ** 기간 설정 시 유용 하다.CDateWithCheck() : 변수가 유효한 날짜로 변경이 가능한 경우에만 변경된다. ** 날짜 형식은 javascript에서 유효성을 확인 하지만 실제 데이타 처리시에도 반드시 확인 하길 추천 한다.Date연산 함수들: 자주 사용되는 연산 규칙들을 함수로 구성 했다.UNIX Time : 초단위로 출력되는 숫자로 경과시간을 초단위로 나타낼 때 유효하다 ** 경과 시간 구하기 iPastSecond = DateTime2UnixTime( dEnd ) - DateTime2UnixTime( dStart )'============================================' DateTime functions'============================================function GetFullDateTime( dNow )GetFullDateTime = Year(dNow)&"."&FillZero(Month(dNow),2)&"."&FillZero(Day(dNow),2) &" "& FillZero(Hour(dNow),2)&":"&FillZero(Minute(dNow),2)&":"&FillZero(Second(dNow),2)end Functionfunction GetFullDateTimeT( dNow )GetFullDateTimeT = Year(dNow)&"-"&FillZero(Month(dNow),2)&"-"&FillZero(Day(dNow),2) &"T"& FillZero(Hour(dNow),2)&":"&FillZero(Minute(dNow),2)&":"&FillZero(Second(dNow),2)end Functionfunction GetFullDateTimeH( dNow )GetFullDateTimeH = Year(dNow)&"-"&FillZero(Month(dNow),2)&"-"&FillZero(Day(dNow),2) &" "& FillZero(Hour(dNow),2)&":"&FillZero(Minute(dNow),2)&":"&FillZero(Second(dNow),2)end Functionfunction GetFullDateTimeKor( dNow )GetFullDateTimeKor = Year(dNow)&"년 "&Month(dNow)&"월 "&Day(dNow)&"일 ("& WeekDayName(Weekday(dNow), True)&") "& FillZero(Hour(dNow),2)&":"&FillZero(Minute(dNow),2)&":"&FillZero(Second(dNow),2)end Functionfunction GetFullDate( dNow )GetFullDate = Year(dNow)&"."&FillZero(Month(dNow),2)&"."&FillZero(Day(dNow),2)end Functionfunction GetFullDateH( dNow )GetFullDateH = Year(dNow)&"-"&FillZero(Month(dNow),2)&"-"&FillZero(Day(dNow),2)end Functionfunction GetFullDateKor( dNow )GetFullDateKor = Year(dNow)&"년 "&Month(dNow)&"월 "&Day(dNow)&"일"end Function'===== only numericfunction GetFullDateTimeON( dNow )GetFullDateTimeON = Year(dNow) & FillZero(Month(dNow),2) & FillZero(Day(dNow),2) & FillZero(Hour(dNow),2) & FillZero(Minute(dNow),2) & FillZero(Second(dNow),2)end Functionfunction GetFullDateTimeONHM( dNow )GetFullDateTimeONHM = Year(dNow) & FillZero(Month(dNow),2) & FillZero(Day(dNow),2) & FillZero(Hour(dNow),2) & FillZero(Minute(dNow),2)end Functionfunction GetTime( dNow )GetTime = FillZero(Hour(dNow),2) &":"& FillZero(Minute(dNow),2) &":"& FillZero(Second(dNow),2)end functionfunction GetTimeON( dNow )GetTimeON = FillZero(Hour(dNow),2) & FillZero(Minute(dNow),2) & FillZero(Second(dNow),2)end functionfunction GetFullDateON( dNow )GetFullDateON = Year(dNow) & FillZero(Month(dNow),2) & FillZero(Day(dNow),2)end Functionfunction GetFullDateON6( dNow )GetFullDateON6 = Right(Year(dNow),2) & FillZero(Month(dNow),2) & FillZero(Day(dNow),2)end Functionfunction ONDateTime2DateTime( cDateTime14 )ONDateTime2DateTime = ONDate2DateTime(Mid(cDateTime14,1,8))&" "&ONTime2DateTime(Mid(cDateTime14,9,6))end functionfunction ONDate2DateTime( cDate8 )dim cReturnif (cDate8="") or ISNull(cDate8) thencReturn = ""elsecReturn = Mid(cDate8,1,4) &"-"& Mid(cDate8,5,2) &"-"& Mid(cDate8,7,2)end ifONDate2DateTime = cReturnend functionfunction ONTime2DateTime( cTime6 )dim cReturnif (cTime6="") or ISNull(cTime6) thencReturn = ""elsecReturn = Mid(cTime6,1,2) &":"& Mid(cTime6,3,2) &":"& Mid(cTime6,5,2)end ifONTime2DateTime = cReturnend functionfunction GetYearMonth( dNow )GetYearMonth = FillZero(Year(dNow),4)&"/"& FillZero(Month(dNow),2)end Functionfunction GetMonthDay( dNow )GetMonthDay = FillZero(Month(dNow),2)&"/"& FillZero(Day(dNow),2)end Functionfunction GetHourMinute( dNow )if IsNull(dNow) thenGetHourMinute = ""elseGetHourMinute = FillZero(Hour(dNow),2)&":"& FillZero(Minute(dNow),2)end ifend Functionfunction GetHourMinuteSecond( dNow )if IsNull(dNow) thenGetHourMinuteSecond = ""elseGetHourMinuteSecond = FillZero(Hour(dNow),2)&":"& FillZero(Minute(dNow),2)&":"& FillZero(Second(dNow),2)end ifend functionfunction CDateWithCheck( cDate8 )dim cDate10cDate10 = ONDate2DateTime(cDate8)if IsDate( cDate10 ) thenCDateWithCheck = CDate( cDate10 )elseCDateWithCheck = nullend ifend functionfunction CDateWithCheck10( cDate10 )if IsDate( cDate10 ) thenCDateWithCheck10 = CDate( cDate10 )elseCDateWithCheck10 = nullend ifend functionfunction CheckDateTime( cDate8 )CheckDateTime = IsDate( ONDate2DateTime(cDate8) )end functionfunction CheckDateTimeNull( cDate8 )CheckDateTimeNull = (IsDate( ONDate2DateTime(cDate8) ) or IsNull(cDate8))end functionfunction GetMonthLastDate( iYear, iMonth )dim cNextMonthFistDateif (iMonth=12) thencNextMonthFistDate=FillZero((iYear+1),4)&"0101"elsecNextMonthFistDate=FillZero(iYear,4)&FillZero((iMonth+1),2)&"01"end ifGetMonthLastDate = GetFullDateON(CDateWithCheck(cNextMonthFistDate)-1)&" 23:59:59"end functionfunction GetMonthLastDay( iYear, iMonth )dim cNextMonthFistDateif (iMonth=12) thencNextMonthFistDate=FillZero((iYear+1),4)&"-01-01"elsecNextMonthFistDate=FillZero(iYear,4)&"-"&FillZero((iMonth+1),2)&"-01"end ifGetMonthLastDay = Day(CDate(cNextMonthFistDate)-1)end functionfunction CmpStartEndMonth( iStartYear, iStartMonth, iEndYear, iEndMonth )dim iCmpStartDate, iCmpEndDateiCmpStartDate = CintZero(FillZero(iStartYear,4)&FillZero(iStartMonth,2))iCmpEndDate = CIntZero(FillZero(iEndYear,4)&FillZero(iEndMonth,2))CmpStartEndMonth = CBool(iCmpStartDate > iCmpEndDate)end function'== Date add functionsfunction YearMonthAddMonthGetYear( iYear, iMonth, iAddMonth )YearMonthAddMonthGetYear = Year(YearMonthAddMonth( iYear, iMonth, iAddMonth ))end functionfunction YearMonthAddMonthGetMonth( iYear, iMonth, iAddMonth )YearMonthAddMonthGetMonth = Month(YearMonthAddMonth( iYear, iMonth, iAddMonth ))end functionfunction YearMonthAddMonth( iYear, iMonth, iAddMonth )YearMonthAddMonth = DateAdd( "m", iAddMonth, CDate(FillZero(iYear,4)&"-"&FillZero(iMonth,2)&"-01") )end functionfunction AddMonthGetMonth( dDate, iMonth )AddMonthGetMonth = Month(AddMonth( dDate, iMonth ))end functionfunction AddMonthGetYear( dDate, iMonth )AddMonthGetYear = Year(AddMonth( dDate, iMonth ))end functionfunction AddMonth( dDate, iMonth )AddMonth = DateAdd( "m", iMonth, dDate )end function'== UNIX Timefunction DateTime2UnixTime( dDateTime )DateTime2UnixTime = DateDiff( "s", "01/01/1970 00:00:00", dDateTime )end functionfunction UnixTime2DateTime( iUnixTime )UnixTime2DateTime = DateAdd( "s", iUnixTime, "01/01/1970 00:00:00" )end functionfunction MonthNameEng( iMonth )dim cReturnselect case iMonthcase 1 cReturn = "January"case 2 cReturn = "February"case 3 cReturn = "March"case 4 cReturn = "April"case 5 cReturn = "May"case 6 cReturn = "June"case 7 cReturn = "July"case 8 cReturn = "August"case 9 cReturn = "September"case 10 cReturn = "October"case 11 cReturn = "November"case 12 cReturn = "December"end selectMonthNameEng = cReturnend function
-
2014-04-30문자 채우기문자(숫자)를 출력하면서 특정문자를 결합하는 경우에 사용한다 - 숫자 "1"을 네자리의 Numneric(빈자리가 "0"로 채워진) 4자리로 변환 하는 경우 1 => "0001" - 좌우측으로 여백문자처리의 경우 • FillString(): 특정문자 채우기 • FillZero(): "0" 문자 채우기 • FillSpace(): 스페이스 채우기문자 자르기mid() 함수를 이용하여 문자를 자르는 경우 2byte 문자도 자릿수에 상관 없이 1문자로 처리되기 떄문에 의도한 것보다 길게 나오는 경우가 많은데 2byte 문자를 감안하여 해당 자릿수에서 문자를 잘라 반환 한다 - 게시판의 제목 등 길어질 수 있는 내용을 좁은 구역에 출력시 유효 - 지정길이보다 긴 경우 +More 사용 • HLeftB(): 2byte 문자 자르기 • HLeftBMore(): 2byte 문자 자른 후 길이가 넘는 경우 "…" 문자 추가<%'===============================================' >> Fill Stuff functions'' FillZero( cString, iLength )' FillSpace( cString, iLength )' FillString( cString, iLength, cFillString )''===============================================function FillZero( cString, iLength )FillZero = FillString( cString, iLength, "0" )end functionfunction FillSpace( cString, iLength )FillSpace = FillString( cString, iLength, " " )end functionfunction FillSpaceRight( cString, iLength )FillSpaceRight = FillStringRight( cString, iLength, " " )end functionfunction FillString( cString, iLength, cFillString )if( iLength >Len(cString) ) thenFillString = ( String( iLength -Len( cString ), cFillString ) & cString )elseFillString = cStringend ifend functionfunction FillStringRight( cString, iLength, cFillString )if( iLength >Len(cString) ) thenFillStringRight = ( cString & String( iLength -Len( cString ), cFillString ) )elseFillStringRight = cStringend ifend functionfunction HLeftB( cString, iLen ) dim i, c, a, bdim cReturnb = 0cReturn = ""if not IsNull(cString) thenfor i = 1 to Len(cString)c = mid(cString,i,1)a = asc(c)cReturn = cReturn&cif (a>255 or a<0) thenb = b+2elseb = b+1end ifif (iLen=<b) thenexit forend ifnextend ifHLeftB = cReturnend functionfunction HLeftBMore( cString, iLen ) dim cc = HLeftB( cString, iLen ) if (cString>c) thenc = c &"…"end ifHLeftBMore = cend function%>
1
