Commit b7992b867079155674555b472bb4c3f68c78d23d

Authored by Alain Klotz
1 parent 5b835b38
Exists in dev

Correction d'un bog dans la representation digits des dates.

Showing 1 changed file with 27 additions and 28 deletions   Show diff stats
src/utils/celme/dates.py
... ... @@ -498,39 +498,38 @@ class Date:
498 498 .. note:: Prefer using objdate.date() followed by objdate.digits().
499 499 """
500 500 error = 0
501   - k1 = string.find("-",1)
502   - k2 = string.find("-",k1+1)
503   - kt = string.find("T",k2+1)
504   - if (kt==-1):
505   - kt = string.find("T",k2+1)
506   - k3 = string.find(":",kt+1)
507   - k4 = string.find(":",k3+1)
508 501 d=1
509 502 hh=0
510 503 mm=0
511 504 ss=0.0
512   - if (k2 > -1):
513   - y = int(string[0:k1])
514   - m = int(string[k1+1:k2])
515   - if (kt == -1):
516   - d = float(string[k2+1:])
517   - else:
518   - d = int(string[k2+1:kt])
519   - if (k3 > -1):
520   - hh = int(string[kt+1:k3])
521   - d += hh/24.
522   - if (k4 == -1):
523   - mm = float(string[k3+1:])
524   - d += mm/1440.
525   - else:
526   - mm = int(string[k3+1:k4])
527   - d += mm/1440.
528   - ss = float(string[k4+1:])
529   - d += ss/86400.
530   - error, jd = self.date_ymd2jd(y,m,d)
  505 + if len(string)>=4:
  506 + y = int(string[0:4])
531 507 else:
532   - # pb format
533   - error = 1
  508 + y = int(string)
  509 + if len(string)>=6:
  510 + m = int(string[4:6])
  511 + else:
  512 + m = 1
  513 + if len(string)>=8:
  514 + d = int(string[6:8])
  515 + else:
  516 + d = 1
  517 + if len(string)>=10:
  518 + hh = int(string[8:10])
  519 + else:
  520 + hh = 0
  521 + if len(string)>=12:
  522 + mm = int(string[10:12])
  523 + else:
  524 + mm = 0
  525 + if len(string)>12:
  526 + ss = float(string[12:])
  527 + else:
  528 + ss = 0
  529 + d += hh/24.
  530 + d += mm/1440.
  531 + d += ss/86400.
  532 + error, jd = self.date_ymd2jd(y,m,d)
534 533 return error, jd
535 534  
536 535 def date_jd2digits(self, jd, nb_subdigit=3):
... ...