mirror of
				https://github.com/graphql-python/graphene.git
				synced 2025-10-31 07:57:26 +03:00 
			
		
		
		
	Use aniso8601 instead of iso8601
This commit is contained in:
		
							parent
							
								
									3ee94131ae
								
							
						
					
					
						commit
						b4255e55fd
					
				|  | @ -3,17 +3,10 @@ from __future__ import absolute_import | ||||||
| import datetime | import datetime | ||||||
| 
 | 
 | ||||||
| from graphql.language import ast | from graphql.language import ast | ||||||
|  | from aniso8601 import parse_datetime, parse_date, parse_time | ||||||
| 
 | 
 | ||||||
| from .scalars import Scalar | from .scalars import Scalar | ||||||
| 
 | 
 | ||||||
| try: |  | ||||||
|     import iso8601 |  | ||||||
| except ImportError: |  | ||||||
|     raise ImportError( |  | ||||||
|         "iso8601 package is required for DateTime Scalar.\n" |  | ||||||
|         "You can install it using: pip install iso8601." |  | ||||||
|     ) |  | ||||||
| 
 |  | ||||||
| 
 | 
 | ||||||
| class Date(Scalar): | class Date(Scalar): | ||||||
|     ''' |     ''' | ||||||
|  | @ -38,7 +31,7 @@ class Date(Scalar): | ||||||
| 
 | 
 | ||||||
|     @staticmethod |     @staticmethod | ||||||
|     def parse_value(value): |     def parse_value(value): | ||||||
|         return iso8601.parse_date(value).date() |         return parse_date(value) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class DateTime(Scalar): | class DateTime(Scalar): | ||||||
|  | @ -62,7 +55,7 @@ class DateTime(Scalar): | ||||||
| 
 | 
 | ||||||
|     @staticmethod |     @staticmethod | ||||||
|     def parse_value(value): |     def parse_value(value): | ||||||
|         return iso8601.parse_date(value) |         return parse_datetime(value) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class Time(Scalar): | class Time(Scalar): | ||||||
|  | @ -71,7 +64,6 @@ class Time(Scalar): | ||||||
|     specified by |     specified by | ||||||
|     [iso8601](https://en.wikipedia.org/wiki/ISO_8601). |     [iso8601](https://en.wikipedia.org/wiki/ISO_8601). | ||||||
|     ''' |     ''' | ||||||
|     epoch_date = '1970-01-01' |  | ||||||
| 
 | 
 | ||||||
|     @staticmethod |     @staticmethod | ||||||
|     def serialize(time): |     def serialize(time): | ||||||
|  | @ -87,5 +79,4 @@ class Time(Scalar): | ||||||
| 
 | 
 | ||||||
|     @classmethod |     @classmethod | ||||||
|     def parse_value(cls, value): |     def parse_value(cls, value): | ||||||
|         dt = iso8601.parse_date('{}T{}'.format(cls.epoch_date, value)) |         return parse_time(value) | ||||||
|         return datetime.time(dt.hour, dt.minute, dt.second, dt.microsecond, dt.tzinfo) |  | ||||||
|  |  | ||||||
							
								
								
									
										1
									
								
								setup.py
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								setup.py
									
									
									
									
									
								
							|  | @ -90,6 +90,7 @@ setup( | ||||||
|         'graphql-core>=2.0,<3', |         'graphql-core>=2.0,<3', | ||||||
|         'graphql-relay>=0.4.5,<1', |         'graphql-relay>=0.4.5,<1', | ||||||
|         'promise>=2.1,<3', |         'promise>=2.1,<3', | ||||||
|  |         'aniso8601>=3,<4', | ||||||
|     ], |     ], | ||||||
|     tests_require=tests_require, |     tests_require=tests_require, | ||||||
|     extras_require={ |     extras_require={ | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user