NRAO Home > CASA > CASA Toolkit Reference Manual
quanta.time - Function

1.5.1 show a time (or date) as a formatted string


Description

time converts a time quantity to a formatted string. The formatting information is a precision (0 is default, 6 includes hh.mm.ss) and a string array of codes (no-case, minimax match): Codes include:

clean
delete leading/trailing superfluous separators
no_d
do not show hours part
no_dm
do not show hours and minutes part
ymd
include a date as yyyy/mm/dd (date is by default not shown)
dmy
include a date as ddMMMyyyy (date is by default not shown)
mjd
include a date as Modified Julian Day (date is by default not shown)
fits
include a date and show time in FITS format: le from OS
angle
show in angle (dd.mm.ss.ttt) rather than time format
day
prefix day-of-week to output
local
show local time rather than UTC (add timezone offset)
no_time
suppress printing of time part

If a multi-dimensional value is given for the value v, the returned value is a string vector of a length equal to last dimension. Each string has a number of fields equal to the number of elements in all earlier dimensions. If the showform is T, each vector element is surrounded by a pair of square brackets if there is more than one entry, and fields are separated by a ’,’.

Arguments





Inputs

v

time quantity value to output

allowed:

variant

Default:

prec

number of digits shown

allowed:

int

Default:

0

form

formatting information in coded string array

allowed:

stringArray

Default:

showform

show square brackets and separating ,

allowed:

bool

Default:

false

Returns
stringArray

Example

 
 
"""  
#  
print "\t----\t time Ex 1 \t----"  
tu = qa.quantity(’today’) # a time  
print tu  
#{’value’: 54175.708981504627, ’unit’: ’d’}  
print qa.time(tu) # default format  
#17:00:56  
print qa.time(tu,form="dmy")   # show date  
#16-Mar-2007/17:00:56  
print qa.time(tu,form=["ymd","day"]) # and day  
#Fri-2007/03/16/17:00:56  
print qa.time(tu,form="fits")           # FITS format  
#2007-03-16T17:00:56  
print qa.time(tu,form=["fits","local"]) # local FITS format  
#2007-03-16T10:00:56-07:00  
print qa.time(tu,form=["ymd","local"])  # local time  
#2007/03/16/10:00:56  
#  
"""  
 

__________________________________________________________________


More information about CASA may be found at the CASA web page

Copyright © 2016 Associated Universities Inc., Washington, D.C.

This code is available under the terms of the GNU General Public Lincense


Home | Contact Us | Directories | Site Map | Help | Privacy Policy | Search