| 
									
										
										
										
											2018-07-21 22:57:21 +08:00
										 |  |  | #include "..\e2dcommon.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | using namespace std::chrono; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | e2d::Time::Time() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-22 00:41:24 +08:00
										 |  |  | time_t e2d::Time::getTimeStamp() const | 
					
						
							| 
									
										
										
										
											2018-07-21 22:57:21 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-07-22 00:41:24 +08:00
										 |  |  | 	auto now = time_point_cast<milliseconds>(time).time_since_epoch(); | 
					
						
							|  |  |  | 	return static_cast<time_t>(now.count()); | 
					
						
							| 
									
										
										
										
											2018-07-21 22:57:21 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-22 00:41:24 +08:00
										 |  |  | e2d::Time e2d::Time::operator+(Duration const & other) const | 
					
						
							| 
									
										
										
										
											2018-07-21 22:57:21 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-07-22 00:41:24 +08:00
										 |  |  | 	Time result; | 
					
						
							|  |  |  | 	result.time = time - other.ms; | 
					
						
							|  |  |  | 	return std::move(result); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | e2d::Duration e2d::Time::operator-(Time const & other) const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int ms = static_cast<int>(duration_cast<milliseconds>(time - other.time).count()); | 
					
						
							|  |  |  | 	return std::move(Duration(ms)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | e2d::Time e2d::Time::now() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	Time now; | 
					
						
							|  |  |  | 	now.time = steady_clock::now(); | 
					
						
							|  |  |  | 	return std::move(now); | 
					
						
							| 
									
										
										
										
											2018-07-21 22:57:21 +08:00
										 |  |  | } |