Class: Mysql::Time
- Inherits:
-
Object
- Object
- Mysql::Time
- Defined in:
- lib/mysql.rb,
ext/mysql/ext.c
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
Returns a new instance of Time.
1057 1058 1059 1060 1061 |
# File 'lib/mysql.rb', line 1057 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
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 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 |
# File 'lib/mysql.rb', line 1048 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
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 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 |
# File 'lib/mysql.rb', line 1048 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
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 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 |
# File 'lib/mysql.rb', line 1048 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
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 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 |
# File 'lib/mysql.rb', line 1048 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
Returns negative flag.
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 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 |
# File 'lib/mysql.rb', line 1048 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
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 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 |
# File 'lib/mysql.rb', line 1048 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
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 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 |
# File 'lib/mysql.rb', line 1048 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
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 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 |
# File 'lib/mysql.rb', line 1048 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
1068 1069 1070 1071 1072 1073 |
# File 'lib/mysql.rb', line 1068 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
1076 1077 1078 |
# File 'lib/mysql.rb', line 1076 def eql?(other) self == other end |
#inspect ⇒ Object
1098 1099 1100 |
# File 'lib/mysql.rb', line 1098 def inspect sprintf "#<#{self.class.name}:%04d-%02d-%02d %02d:%02d:%02d>", year, mon, day, hour, min, sec end |
#to_i ⇒ Integer
Returns yyyymmddHHMMSS.
1093 1094 1095 |
# File 'lib/mysql.rb', line 1093 def to_i sprintf("%04d%02d%02d%02d%02d%02d", year, mon, day, hour, min, sec).to_i end |
#to_s ⇒ String
Returns “yyyy-mm-dd HH:MM:SS”.
1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 |
# File 'lib/mysql.rb', line 1081 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 |