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