ExtJS 和暦

 
 
平成のみ和暦フォーマット設定関数設定
 
◎ 1988年以前は全て0
◎ 元号は無関知
◎ フォーマット記号 e:和暦、E:2桁和暦(1桁時は左に0)
 
 

[javascript]
// 西暦 → 和暦
Ext.Date.formatCodes.e =
‘( Ext.Date.format(this, "Y") < 1988)
? 0<br />
: Ext.Date.format(this, "Y") – 1988
‘;
Ext.Date.formatCodes.E =
‘Ext.String.leftPad(
Ext.Date.format(this, "e")
, 2
, "0"
)
‘;

// 和暦 → 西暦
Ext.Date.parseCodes.e =
{ g : 1
, c : ‘ var ty = parseInt(results[{0}]);n’
+ ‘y = 1988 + ty;n’
, s : ‘(\d{1,2})’
};
Ext.Date.parseCodes.E =
{ g : 1
, c : ‘var ty = parseInt(results[{0}]);n’
+ ‘y = 1988 + ty;n’
, s : ‘(\d{2})’
};
[/javascript]

 
 

回回回 西暦 → 和暦 サンプル
 
■ var dt = new Date() 
----------------------------------------------------------

 

----------------------------------------------------------
 
■ Ext.Date.format(dt, 'E-m-d')
----------------------------------------------------------

 

----------------------------------------------------------
 
 
回回回  和暦 → 西暦 サンプル
 
----------------------------------------------------------

 

 

----------------------------------------------------------
 
 
[javascript]
Ext.create('Ext.form.field.Date', {
format: 'E/m/d'
, altFormats: 'E/m/d|Y/m/d'
, value: Ext.Date.format(new Date(), 'Y/m/d')
});
[/javascript]


コメント

コメントをお寄せください。

コメントの投稿

* コメントフィード