202
202
UTC = datetime .timezone .utc
203
203
204
204
205
+ @_api .caching_module_getattr
206
+ class __getattr__ :
207
+ JULIAN_OFFSET = _api .deprecated ("3.7" )(property (lambda self : 1721424.5 ))
208
+ # Julian date at 0000-12-31
209
+ # note that the Julian day epoch is achievable w/
210
+ # np.datetime64('-4713-11-24T12:00:00'); datetime64 is proleptic
211
+ # Gregorian and BC has a one-year offset. So
212
+ # np.datetime64('0000-12-31') - np.datetime64('-4713-11-24T12:00') =
213
+ # 1721424.5
214
+ # Ref: https://en.wikipedia.org/wiki/Julian_day
215
+
216
+
205
217
def _get_tzinfo (tz = None ):
206
218
"""
207
219
Generate tzinfo from a string or return tzinfo. If None,
@@ -225,12 +237,6 @@ def _get_tzinfo(tz=None):
225
237
# Time-related constants.
226
238
EPOCH_OFFSET = float (datetime .datetime (1970 , 1 , 1 ).toordinal ())
227
239
# EPOCH_OFFSET is not used by matplotlib
228
- JULIAN_OFFSET = 1721424.5 # Julian date at 0000-12-31
229
- # note that the Julian day epoch is achievable w/
230
- # np.datetime64('-4713-11-24T12:00:00'); datetime64 is proleptic
231
- # Gregorian and BC has a one-year offset. So
232
- # np.datetime64('0000-12-31') - np.datetime64('-4713-11-24T12:00') = 1721424.5
233
- # Ref: https://en.wikipedia.org/wiki/Julian_day
234
240
MICROSECONDLY = SECONDLY + 1
235
241
HOURS_PER_DAY = 24.
236
242
MIN_PER_HOUR = 60.
@@ -457,6 +463,7 @@ def date2num(d):
457
463
return d if iterable else d [0 ]
458
464
459
465
466
+ @_api .deprecated ("3.7" )
460
467
def julian2num (j ):
461
468
"""
462
469
Convert a Julian date (or sequence) to a Matplotlib date (or sequence).
@@ -476,10 +483,11 @@ def julian2num(j):
476
483
ep0 = np .datetime64 ('0000-12-31T00:00:00' , 'h' ).astype (float ) / 24.
477
484
# Julian offset defined above is relative to 0000-12-31, but we need
478
485
# relative to our current epoch:
479
- dt = JULIAN_OFFSET - ep0 + ep
486
+ dt = __getattr__ ( " JULIAN_OFFSET" ) - ep0 + ep
480
487
return np .subtract (j , dt ) # Handles both scalar & nonscalar j.
481
488
482
489
490
+ @_api .deprecated ("3.7" )
483
491
def num2julian (n ):
484
492
"""
485
493
Convert a Matplotlib date (or sequence) to a Julian date (or sequence).
@@ -498,7 +506,7 @@ def num2julian(n):
498
506
ep0 = np .datetime64 ('0000-12-31T00:00:00' , 'h' ).astype (float ) / 24.
499
507
# Julian offset defined above is relative to 0000-12-31, but we need
500
508
# relative to our current epoch:
501
- dt = JULIAN_OFFSET - ep0 + ep
509
+ dt = __getattr__ ( " JULIAN_OFFSET" ) - ep0 + ep
502
510
return np .add (n , dt ) # Handles both scalar & nonscalar j.
503
511
504
512
0 commit comments