Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1#!/usr/local/bin/python 

2# encoding: utf-8 

3""" 

4*Report current time in various formats* 

5 

6:Author: 

7 David Young 

8""" 

9from __future__ import division 

10from past.utils import old_div 

11from builtins import object 

12import sys 

13import os 

14import math 

15import time 

16os.environ['TERM'] = 'vt100' 

17from fundamentals import tools 

18 

19class now(object): 

20 """ 

21 *Report the current time into various formats* 

22 

23 **Key Arguments** 

24 

25 - ``log`` -- logger 

26 - ``settings`` -- the settings dictionary 

27  

28 """ 

29 # Initialisation 

30 

31 def __init__( 

32 self, 

33 log, 

34 settings=False, 

35 

36 ): 

37 self.log = log 

38 log.debug("instansiating a new 'now' object") 

39 self.settings = settings 

40 # xt-self-arg-tmpx 

41 

42 # Initial Actions 

43 

44 return None 

45 

46 def get_mjd(self): 

47 """ 

48 *Get the current time as an MJD* 

49 

50 **Return** 

51 

52 - ``mjd`` -- the current MJD as a float 

53  

54 

55 **Usage** 

56 

57  

58 .. todo:: 

59 

60 - add clutil 

61 - remove `getCurrentMJD` from all other code 

62 

63 ```python 

64 from astrocalc.times import now 

65 mjd = now( 

66 log=log 

67 ).get_mjd() 

68 ``` 

69 """ 

70 self.log.debug('starting the ``get_mjd`` method') 

71 

72 jd = old_div(time.time(), 86400.0) + 2440587.5 

73 mjd = jd - 2400000.5 

74 

75 self.log.debug('completed the ``get_mjd`` method') 

76 return mjd 

77 

78 # xt-class-method