Class: Mysql::Time
Instance Attribute Summary collapse
- #day ⇒ Integer
- #hour ⇒ Integer
- #minute ⇒ Integer (also: #min)
- #month ⇒ Integer (also: #mon)
-
#neg ⇒ Boolean
Negative flag.
- #second ⇒ Integer (also: #sec)
- #second_part ⇒ Integer
- #year ⇒ Integer
Instance Method Summary collapse
- #==(other) ⇒ Object
- #eql?(other) ⇒ Boolean
-
#initialize(year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0, neg = false, second_part = 0) ⇒ Time
constructor
A new instance of Time.
- #inspect ⇒ Object
-
#to_i ⇒ Integer
YyyymmddHHMMSS.
-
#to_s ⇒ String
“yyyy-mm-dd HH:MM:SS”.
Constructor Details
#initialize(year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0, neg = false, second_part = 0) ⇒ Time
1046 1047 1048 1049 1050 |
# File 'lib/vendor/mysql.rb', line 1046 def initialize(year=0, month=0, day=0, hour=0, minute=0, second=0, neg=false, second_part=0) @date_flag = !(hour && minute && second) @year, @month, @day, @hour, @minute, @second, @neg, @second_part = year.to_i, month.to_i, day.to_i, hour.to_i, minute.to_i, second.to_i, neg, second_part.to_i end |
Instance Attribute Details
#day ⇒ Integer
1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 |
# File 'lib/vendor/mysql.rb', line 1037 class Time # @param [Integer] year # @param [Integer] month # @param [Integer] day # @param [Integer] hour # @param [Integer] minute # @param [Integer] second # @param [Boolean] neg negative flag # @param [Integer] second_part def initialize(year=0, month=0, day=0, hour=0, minute=0, second=0, neg=false, second_part=0) @date_flag = !(hour && minute && second) @year, @month, @day, @hour, @minute, @second, @neg, @second_part = year.to_i, month.to_i, day.to_i, hour.to_i, minute.to_i, second.to_i, neg, second_part.to_i end attr_accessor :year, :month, :day, :hour, :minute, :second, :neg, :second_part alias mon month alias min minute alias sec second # @private def ==(other) other.is_a?(Mysql::Time) && @year == other.year && @month == other.month && @day == other.day && @hour == other.hour && @minute == other.minute && @second == other.second && @neg == neg && @second_part == other.second_part end # @private def eql?(other) self == other end # @return [String] "yyyy-mm-dd HH:MM:SS" def to_s if @date_flag sprintf "%04d-%02d-%02d", year, mon, day elsif year == 0 and mon == 0 and day == 0 h = neg ? hour * -1 : hour sprintf "%02d:%02d:%02d", h, min, sec else sprintf "%04d-%02d-%02d %02d:%02d:%02d", year, mon, day, hour, min, sec end end # @return [Integer] yyyymmddHHMMSS def to_i sprintf("%04d%02d%02d%02d%02d%02d", year, mon, day, hour, min, sec).to_i end # @private def inspect sprintf "#<#{self.class.name}:%04d-%02d-%02d %02d:%02d:%02d>", year, mon, day, hour, min, sec end end |
#hour ⇒ Integer
1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 |
# File 'lib/vendor/mysql.rb', line 1037 class Time # @param [Integer] year # @param [Integer] month # @param [Integer] day # @param [Integer] hour # @param [Integer] minute # @param [Integer] second # @param [Boolean] neg negative flag # @param [Integer] second_part def initialize(year=0, month=0, day=0, hour=0, minute=0, second=0, neg=false, second_part=0) @date_flag = !(hour && minute && second) @year, @month, @day, @hour, @minute, @second, @neg, @second_part = year.to_i, month.to_i, day.to_i, hour.to_i, minute.to_i, second.to_i, neg, second_part.to_i end attr_accessor :year, :month, :day, :hour, :minute, :second, :neg, :second_part alias mon month alias min minute alias sec second # @private def ==(other) other.is_a?(Mysql::Time) && @year == other.year && @month == other.month && @day == other.day && @hour == other.hour && @minute == other.minute && @second == other.second && @neg == neg && @second_part == other.second_part end # @private def eql?(other) self == other end # @return [String] "yyyy-mm-dd HH:MM:SS" def to_s if @date_flag sprintf "%04d-%02d-%02d", year, mon, day elsif year == 0 and mon == 0 and day == 0 h = neg ? hour * -1 : hour sprintf "%02d:%02d:%02d", h, min, sec else sprintf "%04d-%02d-%02d %02d:%02d:%02d", year, mon, day, hour, min, sec end end # @return [Integer] yyyymmddHHMMSS def to_i sprintf("%04d%02d%02d%02d%02d%02d", year, mon, day, hour, min, sec).to_i end # @private def inspect sprintf "#<#{self.class.name}:%04d-%02d-%02d %02d:%02d:%02d>", year, mon, day, hour, min, sec end end |
#minute ⇒ Integer Also known as: min
1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 |
# File 'lib/vendor/mysql.rb', line 1037 class Time # @param [Integer] year # @param [Integer] month # @param [Integer] day # @param [Integer] hour # @param [Integer] minute # @param [Integer] second # @param [Boolean] neg negative flag # @param [Integer] second_part def initialize(year=0, month=0, day=0, hour=0, minute=0, second=0, neg=false, second_part=0) @date_flag = !(hour && minute && second) @year, @month, @day, @hour, @minute, @second, @neg, @second_part = year.to_i, month.to_i, day.to_i, hour.to_i, minute.to_i, second.to_i, neg, second_part.to_i end attr_accessor :year, :month, :day, :hour, :minute, :second, :neg, :second_part alias mon month alias min minute alias sec second # @private def ==(other) other.is_a?(Mysql::Time) && @year == other.year && @month == other.month && @day == other.day && @hour == other.hour && @minute == other.minute && @second == other.second && @neg == neg && @second_part == other.second_part end # @private def eql?(other) self == other end # @return [String] "yyyy-mm-dd HH:MM:SS" def to_s if @date_flag sprintf "%04d-%02d-%02d", year, mon, day elsif year == 0 and mon == 0 and day == 0 h = neg ? hour * -1 : hour sprintf "%02d:%02d:%02d", h, min, sec else sprintf "%04d-%02d-%02d %02d:%02d:%02d", year, mon, day, hour, min, sec end end # @return [Integer] yyyymmddHHMMSS def to_i sprintf("%04d%02d%02d%02d%02d%02d", year, mon, day, hour, min, sec).to_i end # @private def inspect sprintf "#<#{self.class.name}:%04d-%02d-%02d %02d:%02d:%02d>", year, mon, day, hour, min, sec end end |
#month ⇒ Integer Also known as: mon
1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 |
# File 'lib/vendor/mysql.rb', line 1037 class Time # @param [Integer] year # @param [Integer] month # @param [Integer] day # @param [Integer] hour # @param [Integer] minute # @param [Integer] second # @param [Boolean] neg negative flag # @param [Integer] second_part def initialize(year=0, month=0, day=0, hour=0, minute=0, second=0, neg=false, second_part=0) @date_flag = !(hour && minute && second) @year, @month, @day, @hour, @minute, @second, @neg, @second_part = year.to_i, month.to_i, day.to_i, hour.to_i, minute.to_i, second.to_i, neg, second_part.to_i end attr_accessor :year, :month, :day, :hour, :minute, :second, :neg, :second_part alias mon month alias min minute alias sec second # @private def ==(other) other.is_a?(Mysql::Time) && @year == other.year && @month == other.month && @day == other.day && @hour == other.hour && @minute == other.minute && @second == other.second && @neg == neg && @second_part == other.second_part end # @private def eql?(other) self == other end # @return [String] "yyyy-mm-dd HH:MM:SS" def to_s if @date_flag sprintf "%04d-%02d-%02d", year, mon, day elsif year == 0 and mon == 0 and day == 0 h = neg ? hour * -1 : hour sprintf "%02d:%02d:%02d", h, min, sec else sprintf "%04d-%02d-%02d %02d:%02d:%02d", year, mon, day, hour, min, sec end end # @return [Integer] yyyymmddHHMMSS def to_i sprintf("%04d%02d%02d%02d%02d%02d", year, mon, day, hour, min, sec).to_i end # @private def inspect sprintf "#<#{self.class.name}:%04d-%02d-%02d %02d:%02d:%02d>", year, mon, day, hour, min, sec end end |
#neg ⇒ Boolean
1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 |
# File 'lib/vendor/mysql.rb', line 1037 class Time # @param [Integer] year # @param [Integer] month # @param [Integer] day # @param [Integer] hour # @param [Integer] minute # @param [Integer] second # @param [Boolean] neg negative flag # @param [Integer] second_part def initialize(year=0, month=0, day=0, hour=0, minute=0, second=0, neg=false, second_part=0) @date_flag = !(hour && minute && second) @year, @month, @day, @hour, @minute, @second, @neg, @second_part = year.to_i, month.to_i, day.to_i, hour.to_i, minute.to_i, second.to_i, neg, second_part.to_i end attr_accessor :year, :month, :day, :hour, :minute, :second, :neg, :second_part alias mon month alias min minute alias sec second # @private def ==(other) other.is_a?(Mysql::Time) && @year == other.year && @month == other.month && @day == other.day && @hour == other.hour && @minute == other.minute && @second == other.second && @neg == neg && @second_part == other.second_part end # @private def eql?(other) self == other end # @return [String] "yyyy-mm-dd HH:MM:SS" def to_s if @date_flag sprintf "%04d-%02d-%02d", year, mon, day elsif year == 0 and mon == 0 and day == 0 h = neg ? hour * -1 : hour sprintf "%02d:%02d:%02d", h, min, sec else sprintf "%04d-%02d-%02d %02d:%02d:%02d", year, mon, day, hour, min, sec end end # @return [Integer] yyyymmddHHMMSS def to_i sprintf("%04d%02d%02d%02d%02d%02d", year, mon, day, hour, min, sec).to_i end # @private def inspect sprintf "#<#{self.class.name}:%04d-%02d-%02d %02d:%02d:%02d>", year, mon, day, hour, min, sec end end |
#second ⇒ Integer Also known as: sec
1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 |
# File 'lib/vendor/mysql.rb', line 1037 class Time # @param [Integer] year # @param [Integer] month # @param [Integer] day # @param [Integer] hour # @param [Integer] minute # @param [Integer] second # @param [Boolean] neg negative flag # @param [Integer] second_part def initialize(year=0, month=0, day=0, hour=0, minute=0, second=0, neg=false, second_part=0) @date_flag = !(hour && minute && second) @year, @month, @day, @hour, @minute, @second, @neg, @second_part = year.to_i, month.to_i, day.to_i, hour.to_i, minute.to_i, second.to_i, neg, second_part.to_i end attr_accessor :year, :month, :day, :hour, :minute, :second, :neg, :second_part alias mon month alias min minute alias sec second # @private def ==(other) other.is_a?(Mysql::Time) && @year == other.year && @month == other.month && @day == other.day && @hour == other.hour && @minute == other.minute && @second == other.second && @neg == neg && @second_part == other.second_part end # @private def eql?(other) self == other end # @return [String] "yyyy-mm-dd HH:MM:SS" def to_s if @date_flag sprintf "%04d-%02d-%02d", year, mon, day elsif year == 0 and mon == 0 and day == 0 h = neg ? hour * -1 : hour sprintf "%02d:%02d:%02d", h, min, sec else sprintf "%04d-%02d-%02d %02d:%02d:%02d", year, mon, day, hour, min, sec end end # @return [Integer] yyyymmddHHMMSS def to_i sprintf("%04d%02d%02d%02d%02d%02d", year, mon, day, hour, min, sec).to_i end # @private def inspect sprintf "#<#{self.class.name}:%04d-%02d-%02d %02d:%02d:%02d>", year, mon, day, hour, min, sec end end |
#second_part ⇒ Integer
1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 |
# File 'lib/vendor/mysql.rb', line 1037 class Time # @param [Integer] year # @param [Integer] month # @param [Integer] day # @param [Integer] hour # @param [Integer] minute # @param [Integer] second # @param [Boolean] neg negative flag # @param [Integer] second_part def initialize(year=0, month=0, day=0, hour=0, minute=0, second=0, neg=false, second_part=0) @date_flag = !(hour && minute && second) @year, @month, @day, @hour, @minute, @second, @neg, @second_part = year.to_i, month.to_i, day.to_i, hour.to_i, minute.to_i, second.to_i, neg, second_part.to_i end attr_accessor :year, :month, :day, :hour, :minute, :second, :neg, :second_part alias mon month alias min minute alias sec second # @private def ==(other) other.is_a?(Mysql::Time) && @year == other.year && @month == other.month && @day == other.day && @hour == other.hour && @minute == other.minute && @second == other.second && @neg == neg && @second_part == other.second_part end # @private def eql?(other) self == other end # @return [String] "yyyy-mm-dd HH:MM:SS" def to_s if @date_flag sprintf "%04d-%02d-%02d", year, mon, day elsif year == 0 and mon == 0 and day == 0 h = neg ? hour * -1 : hour sprintf "%02d:%02d:%02d", h, min, sec else sprintf "%04d-%02d-%02d %02d:%02d:%02d", year, mon, day, hour, min, sec end end # @return [Integer] yyyymmddHHMMSS def to_i sprintf("%04d%02d%02d%02d%02d%02d", year, mon, day, hour, min, sec).to_i end # @private def inspect sprintf "#<#{self.class.name}:%04d-%02d-%02d %02d:%02d:%02d>", year, mon, day, hour, min, sec end end |
#year ⇒ Integer
1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 |
# File 'lib/vendor/mysql.rb', line 1037 class Time # @param [Integer] year # @param [Integer] month # @param [Integer] day # @param [Integer] hour # @param [Integer] minute # @param [Integer] second # @param [Boolean] neg negative flag # @param [Integer] second_part def initialize(year=0, month=0, day=0, hour=0, minute=0, second=0, neg=false, second_part=0) @date_flag = !(hour && minute && second) @year, @month, @day, @hour, @minute, @second, @neg, @second_part = year.to_i, month.to_i, day.to_i, hour.to_i, minute.to_i, second.to_i, neg, second_part.to_i end attr_accessor :year, :month, :day, :hour, :minute, :second, :neg, :second_part alias mon month alias min minute alias sec second # @private def ==(other) other.is_a?(Mysql::Time) && @year == other.year && @month == other.month && @day == other.day && @hour == other.hour && @minute == other.minute && @second == other.second && @neg == neg && @second_part == other.second_part end # @private def eql?(other) self == other end # @return [String] "yyyy-mm-dd HH:MM:SS" def to_s if @date_flag sprintf "%04d-%02d-%02d", year, mon, day elsif year == 0 and mon == 0 and day == 0 h = neg ? hour * -1 : hour sprintf "%02d:%02d:%02d", h, min, sec else sprintf "%04d-%02d-%02d %02d:%02d:%02d", year, mon, day, hour, min, sec end end # @return [Integer] yyyymmddHHMMSS def to_i sprintf("%04d%02d%02d%02d%02d%02d", year, mon, day, hour, min, sec).to_i end # @private def inspect sprintf "#<#{self.class.name}:%04d-%02d-%02d %02d:%02d:%02d>", year, mon, day, hour, min, sec end end |
Instance Method Details
#==(other) ⇒ Object
1057 1058 1059 1060 1061 1062 |
# File 'lib/vendor/mysql.rb', line 1057 def ==(other) other.is_a?(Mysql::Time) && @year == other.year && @month == other.month && @day == other.day && @hour == other.hour && @minute == other.minute && @second == other.second && @neg == neg && @second_part == other.second_part end |
#eql?(other) ⇒ Boolean
1065 1066 1067 |
# File 'lib/vendor/mysql.rb', line 1065 def eql?(other) self == other end |
#inspect ⇒ Object
1087 1088 1089 |
# File 'lib/vendor/mysql.rb', line 1087 def inspect sprintf "#<#{self.class.name}:%04d-%02d-%02d %02d:%02d:%02d>", year, mon, day, hour, min, sec end |
#to_i ⇒ Integer
1082 1083 1084 |
# File 'lib/vendor/mysql.rb', line 1082 def to_i sprintf("%04d%02d%02d%02d%02d%02d", year, mon, day, hour, min, sec).to_i end |
#to_s ⇒ String
1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 |
# File 'lib/vendor/mysql.rb', line 1070 def to_s if @date_flag sprintf "%04d-%02d-%02d", year, mon, day elsif year == 0 and mon == 0 and day == 0 h = neg ? hour * -1 : hour sprintf "%02d:%02d:%02d", h, min, sec else sprintf "%04d-%02d-%02d %02d:%02d:%02d", year, mon, day, hour, min, sec end end |