Format Date String

function padLeft(nr, n, str) {
return Array(n - String(nr).length + 1).join(str || '0') + nr;
}
if (!Date.prototype.toMyString) {
Date.prototype.toMyString = function() {
var y = this.getFullYear();
var m = this.getMonth() + 1;
var d = this.getDate();
return y + '/' + padLeft(m,2) + '/' + padLeft(d,2);
}
}
console.log(new Date('2012/02/05').toMyString()); // 2012/02/05
view raw formatDate.js hosted with ❤ by GitHub
Date.prototype.addHours = function(h) {
this.setHours(this.getHours() + h);
return this;
};
Date.prototype.toMyDate = function() {
return this.getFullYear() + padLeft(this.getMonth()+1, 2) + padLeft(this.getDate(), 2);
};
Date.prototype.toMyTime = function() {
return padLeft(this.getHours(), 2) + ':' + padLeft(this.getMinutes(), 2) + ':' + padLeft(this.getSeconds(), 2);
};
function padLeft(nr, n, str) {
return Array(n - String(nr).length + 1).join(str || '0') + nr;
}
var now = new Date(),
yesterday = new Date().addHours(-24);
console.log('now time: %s',now.toMyTime());
console.log('now date: %s',now.toMyDate());
console.log('yesterday time: %s',yesterday.toMyTime());
console.log('yesterday date: %s',yesterday.toMyDate());
view raw OtherFunc.js hosted with ❤ by GitHub

編碼轉換

static string CovertEncoding(int intSrcEncode, int intDstEncode, string strSrc)
{
byte[] bSrc = Encoding.GetEncoding(intSrcEncode).GetBytes(strSrc);
byte[] bDst = Encoding.Convert(Encoding.GetEncoding(intSrcEncode), Encoding.GetEncoding(intDstEncode), bSrc);
string strResult = Encoding.GetEncoding(intDstEncode).GetString(bDst);
return strResult;
}
''' <summary>
''' 字串編碼轉換
''' </summary>
''' <param name="intSrcEncode">來源編碼</param>
''' <param name="intDstEncode">目的編碼</param>
''' <param name="strSrc">待轉換字串</param>
''' <returns></returns>
''' <remarks></remarks>
Public Shared Function CovertEncoding(ByVal intSrcEncode As Integer, ByVal intDstEncode As Integer, ByVal strSrc As String) As String
Dim bSrc As Byte() = Encoding.GetEncoding(intSrcEncode).GetBytes(strSrc)
Dim bDst As Byte() = Encoding.Convert(Encoding.GetEncoding(intSrcEncode), Encoding.GetEncoding(intDstEncode), bSrc)
Dim strResult As String = Encoding.GetEncoding(intDstEncode).GetString(bDst)
Return strResult
End Function

[C#].Net編碼轉換 Unicode to Big5 | 好風工作室

Firebug tabs font size too small (Firebug頁籤字型過小)

userChrome.css .innerToolbar, .panelTab-text {font-size-adjust: 0 !important;}
BobChao the Blogger: Firebug 頁籤文字太小的繞路解法