Date/Time Commands

This page includes the following:

format_date()

Utility for transforming dates from the Java internal format. Produces a human-readable date given the number of milliseconds since midnight GMT, Jan. 1, 1970.

Parameters:

  • millis - milliseconds to be converted

Dependencies:

  • Can be called before login

Result:

  • String in the form "2007/1/15 13:21:00 MST"

Example format_date() command line usage:

>>> format_date(millis=1434560000000) 
u'2015/06/17 10:53:20 MDT'

>>> format_date(1434560000000)

Example format_date() script usage:

import sys
from jaws import *

login()
print 'begin output' 
try:
    mils = 1438722042175
    print format_date(mils) 

    print 'end output'

finally:
    logout()

format_duration()

Utility for converting a duration expressed in millis into a human-readable form.

Parameters:

  • millis - milliseconds to be converted

Dependencies:

  • Can be called before login

Result:

  • String in the form "104 days, 12:15:30"

Example format_duration() command line usage:

>>> format_duration(millis=1000000000) 
u'11 days, 13:46:40'

>>> format_duration(1000)

Example format_duration() script usage:

import sys
from jaws import *

login()
print 'begin output' 
try:
    pred = predicted_durations() 
    for p in pred:
    print p.job() + ", " + p.scheduler(
) + ": "+ format_duration(p.duration()) 

    print 'end output'

finally:
    logout()

parse_date()

Utility for transforming dates to the Java internal format. Accepts a human-readable date and converts it to the number of milliseconds since midnight GMT, Jan. 1, 1970.

Parameters:

  • date - String in the form "2007/1/15 13:21:00 MST"

Dependencies:

  • Can be called before login

Result:

  • Date in Java internal date format

Example parse_date() command line usage:

>>> parse_date(date='2007/1/15 13:21:00 MST') 
1168892460000L

>>> parse_date('2007/1/15 13:21:00 MST')

Example parse_date() script usage:

import sys
from jaws import *

login()
print 'begin output' 
try:
    usr = user_sessions() 
    for u in usr:
      print u.user() + ": " + str(parse_date(u.login_time())) 

    print 'end output'

finally:
    logout()

parse_duration()

Parse a duration. The API specifies that durations should be either a number of milliseconds, or a string in 'hh:mm:ss' format. In fact, this method also allows a true Duration as well.

Parameters:

  • None

Dependencies:

  • Can be called before login

Result:

  • The duration of the given milliseconds or string value

Example parse_duration() command line usage:

>>> parse_duration(5000000) 
Duration[1:23:20]

>>> parse_duration('10:12:05') 
Duration[10:12:05]

Example parse_duration() script usage:

import sys
from jaws import *

login()
print 'begin output' 
try:
    jbstrms = jobstreams() 
    for j in jbstrms:
      runs = jobstream_runs2(j) 
      start = parse_date(runs[0][0]) 
      end = parse_date(runs[0][1]) 
      time = end-start
      print j + ' first run duration: ' + str(parse_duration(time)) 

    print 'end output'

finally:
    logout()

use_millis_in_date_format()

Switch the data format to represent the milliseconds in a time.

Parameters:

  • useMillis (optional) - set to false to return to date strings without milliseconds

    Default: True

Dependencies:

  • Can be called before login

Result:

  • If False, date strings are returned without milliseconds
  • If True, date strings are returned with milliseconds

Example use_millis_in_date_format() command line usage:

>>> use_millis_in_date_format(useMillis=False)
>>> format_date(1434560000000) 
u'2015/06/17 10:53:20 MDT'

>>> use_millis_in_date_format(useMillis=True)
>>> format_date(1434560000000) 
u'2015/06/17 10:53:20.000 MDT'

>>> use_millis_in_date_format(False)
>>> use_millis_in_date_format(True)

Example use_millis_in_date_format() script usage:

import sys
from jaws import *

login()
print 'begin output' 
try:
    use_millis_in_date_format(False) 
    print format_date(1434560000000)

    print 'end output' 

finally:
    logout()