Class: AlDate

Inherits:
AlTimestamp show all
Defined in:
lib/al_form.rb

Overview

Note:

日付ウィジェット

年月日を扱う 内部的には時刻を0時に固定したTimeオブジェクトで保存する。

Constant Summary collapse

STRFTIME_FORMAT =
"%Y-%m-%d"

Instance Attribute Summary

Attributes inherited from AlTimestamp

#max, #min

Attributes inherited from AlWidget

#filter, #foreign, #hidden, #label, #message, #name, #required, #tag_attr, #tag_type, #value

Instance Method Summary collapse

Methods inherited from AlTimestamp

#make_tag, #validate

Methods inherited from AlWidget

#make_tag, #set_attr, #set_value

Constructor Details

#initialize(name, arg = {}) ⇒ AlDate

(AlDate) constructor

Parameters:

  • name (String)

    ウィジェット識別名 英文字を推奨

  • arg (Hash) (defaults to: {})

    引数ハッシュ

See Also:



1618
1619
1620
1621
# File 'lib/al_form.rb', line 1618

def initialize( name, arg = {} )
  super( name, arg )
  @value = normalize( @value )  if @value.class == Time
end

Instance Method Details

#make_value(*arg) ⇒ String

(AlDate) HTML値の生成

Parameters:

  • arg (String, Time)

    表示値。指定なければ内部値を使う。

Returns:

  • (String)

    html文字列



1630
1631
1632
1633
1634
1635
1636
1637
# File 'lib/al_form.rb', line 1630

def make_value( *arg )
  v = arg.empty? ? @value : arg[0]
  if v.class == Time
    return v.strftime('%Y-%m-%d')
  else
    return Alone::escape_html( v )
  end
end