Coverage for astrocalc/times/now.py : 100%

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*
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
19class now(object):
20 """
21 *Report the current time into various formats*
23 **Key Arguments**
25 - ``log`` -- logger
26 - ``settings`` -- the settings dictionary
28 """
29 # Initialisation
31 def __init__(
32 self,
33 log,
34 settings=False,
36 ):
37 self.log = log
38 log.debug("instansiating a new 'now' object")
39 self.settings = settings
40 # xt-self-arg-tmpx
42 # Initial Actions
44 return None
46 def get_mjd(self):
47 """
48 *Get the current time as an MJD*
50 **Return**
52 - ``mjd`` -- the current MJD as a float
55 **Usage**
58 .. todo::
60 - add clutil
61 - remove `getCurrentMJD` from all other code
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')
72 jd = old_div(time.time(), 86400.0) + 2440587.5
73 mjd = jd - 2400000.5
75 self.log.debug('completed the ``get_mjd`` method')
76 return mjd
78 # xt-class-method