| 
									
										
										
										
											2018-07-21 22:57:21 +08:00
										 |  |  | #include "..\e2dcommon.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | using namespace std::chrono; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | e2d::Duration::Duration() | 
					
						
							| 
									
										
										
										
											2018-07-22 20:09:14 +08:00
										 |  |  | 	: _ms() | 
					
						
							| 
									
										
										
										
											2018-07-21 22:57:21 +08:00
										 |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-22 00:41:24 +08:00
										 |  |  | e2d::Duration::Duration(int ms) | 
					
						
							| 
									
										
										
										
											2018-07-22 20:09:14 +08:00
										 |  |  | 	: _ms(ms) | 
					
						
							| 
									
										
										
										
											2018-07-21 22:57:21 +08:00
										 |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-22 20:09:14 +08:00
										 |  |  | e2d::Duration::Duration(std::chrono::milliseconds ms) | 
					
						
							|  |  |  | 	: _ms(ms) | 
					
						
							| 
									
										
										
										
											2018-07-21 22:57:21 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-07-22 00:41:24 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-22 20:09:14 +08:00
										 |  |  | int e2d::Duration::milliseconds() const | 
					
						
							| 
									
										
										
										
											2018-07-22 00:41:24 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-07-22 20:09:14 +08:00
										 |  |  | 	return static_cast<int>(_ms.count()); | 
					
						
							| 
									
										
										
										
											2018-07-22 00:41:24 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-22 20:09:14 +08:00
										 |  |  | double e2d::Duration::seconds() const | 
					
						
							| 
									
										
										
										
											2018-07-22 00:41:24 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-07-22 20:09:14 +08:00
										 |  |  | 	return _ms.count() / 1000.0; | 
					
						
							| 
									
										
										
										
											2018-07-22 00:41:24 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool e2d::Duration::operator==(const Duration & other) const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-07-22 20:09:14 +08:00
										 |  |  | 	return _ms == other._ms; | 
					
						
							| 
									
										
										
										
											2018-07-22 00:41:24 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool e2d::Duration::operator!=(const Duration & other) const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-07-22 20:09:14 +08:00
										 |  |  | 	return _ms != other._ms; | 
					
						
							| 
									
										
										
										
											2018-07-22 00:41:24 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool e2d::Duration::operator>(const Duration & other) const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-07-22 20:09:14 +08:00
										 |  |  | 	return _ms > other._ms; | 
					
						
							| 
									
										
										
										
											2018-07-22 00:41:24 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool e2d::Duration::operator>=(const Duration & other) const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-07-22 20:09:14 +08:00
										 |  |  | 	return _ms >= other._ms; | 
					
						
							| 
									
										
										
										
											2018-07-22 00:41:24 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool e2d::Duration::operator<(const Duration & other) const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-07-22 20:09:14 +08:00
										 |  |  | 	return _ms < other._ms; | 
					
						
							| 
									
										
										
										
											2018-07-22 00:41:24 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool e2d::Duration::operator<=(const Duration & other) const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-07-22 20:09:14 +08:00
										 |  |  | 	return _ms <= other._ms; | 
					
						
							| 
									
										
										
										
											2018-07-22 00:41:24 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | e2d::Duration e2d::Duration::operator+(Duration const & other) const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-07-22 20:09:14 +08:00
										 |  |  | 	return std::move(Duration(_ms + other._ms)); | 
					
						
							| 
									
										
										
										
											2018-07-22 00:41:24 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | e2d::Duration e2d::Duration::operator-(Duration const & other) const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-07-22 20:09:14 +08:00
										 |  |  | 	return std::move(Duration(_ms - other._ms)); | 
					
						
							| 
									
										
										
										
											2018-07-21 22:57:21 +08:00
										 |  |  | } |