| 
									
										
										
										
											2020-06-02 22:09:48 +08:00
										 |  |  | /* | 
					
						
							|  |  |  | 	MIT License http://www.opensource.org/licenses/mit-license.php
 | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | "use strict"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-23 02:32:23 +08:00
										 |  |  | /** @typedef {import("./ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */ | 
					
						
							|  |  |  | /** @typedef {import("./ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-02 22:09:48 +08:00
										 |  |  | class DateObjectSerializer { | 
					
						
							| 
									
										
										
										
											2023-05-23 02:32:23 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {Date} obj date | 
					
						
							|  |  |  | 	 * @param {ObjectSerializerContext} context context | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	serialize(obj, context) { | 
					
						
							|  |  |  | 		context.write(obj.getTime()); | 
					
						
							| 
									
										
										
										
											2020-06-02 22:09:48 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2024-07-31 12:23:44 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-23 02:32:23 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {ObjectDeserializerContext} context context | 
					
						
							|  |  |  | 	 * @returns {Date} date | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	deserialize(context) { | 
					
						
							|  |  |  | 		return new Date(context.read()); | 
					
						
							| 
									
										
										
										
											2020-06-02 22:09:48 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | module.exports = DateObjectSerializer; |