Important This documentation space contains information about PATROL Agents when deployed in a TrueSight Operations Management environment. If you are a BMC Helix Operations Management user, see PATROL Agent 22.3.01 for BMC Helix Operations Management.

convert_date()


Convert the Gregorian date and time to the number of seconds that have elapsed since 00:00:00 GMT January 1, 1970.

Syntax

convert_date(day date month year time [timezone],[timezone])
convert_date(day month date time [timezone] year,[timezone])
convert_date(day month date time year,[timezone])

 

Parameters

Parameter

Definition

day

three-character string representing the day of the week*Valid Values* 
Sun Mon Tue Wed Thu Fri Sat

date

integer day of the month*Valid Values* 
1-31

month

three-character string representing the month Valid Values 
Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec

year

integer year*Valid Values* 
1902-2037

time

eight-character string in the form hh : mm : ss representing the time*Valid Values* 
hh hours (00-23) 
mm minutes (00-59) 
ss seconds (00-59)

timezone

optional time zone for which the conversion is being performed*Valid Values*

  • A through I, K through Z-- military time zones
  • ADT-- Atlantic Daylight
  • AHST-- Alaska-Hawaii Standard
  • AST-- Atlantic Standard
  • AT-- Azores
  • BST-- British Summer
  • BT-- Baghdad, USSR Zone 2
  • CADT-- Central Australian Daylight
  • CAST-- Central Australian Standard
  • CAT-- Central Alaska
  • CCT-- China Coast, USSR Zone 7
  • CDT-- Central Daylight
  • CET-- Central European
  • CST-- Central Standard
  • EADT-- Eastern Australian Daylight
  • EAST-- Eastern Australian Standard
  • EDT-- Eastern Daylight
  • EET-- Eastern Europe, USSR Zone 1
  • EST-- Eastern Standard
  • FST-- French Summer
  • FWT-- French Winter
  • GMT-- Greenwich Mean
  • GST-- Guam Standard, USSR Zone 9
  • HDT-- Hawaii Daylight
  • HST-- Hawaii Standard
  • IDLE-- International Date Line East
  • IDLW-- International Date Line West
  • IST-- Indian Standard
  • IT-- Iran
  • JST-- Japan Standard, USSR Zone 8
  • JT-- Java
  • MDT-- Mountain Daylight
  • MEST-- Middle European Summer
  • MET-- Middle European
  • MEWT-- Middle European Winter

timezone 
(continued)

  • IT-- Iran
  • JST-- Japan Standard, USSR Zone 8
  • JT-- Java
  • MDT-- Mountain Daylight
  • MEST-- Middle European Summer
  • MET-- Middle European
  • MEWT-- Middle European Winter
  • MST-- Mountain Standard
  • NDT-- Newfoundland Daylight
  • NFT-- Newfoundland
  • NST-- Newfoundland Standard
  • NT-- Nome
  • NZDT-- New Zealand Daylight
  • NZST-- New Zealand Standard
  • NZT-- New Zealand
  • PDT-- Pacific Daylight
  • PST-- Pacific Standard
  • SST-- Swedish Summer
  • SWT-- Swedish Winter
  • TZ1-- See User-Defined Time Zone on next page.
  • TZ2-- See User-Defined Time Zone on next page.
  • UT or UTC-- Universal (Coordinated)
  • WADT-- West Australian Daylight
  • WAST-- West Australian Standard
  • WAT-- West Africa
  • WET-- Western European
  • YDT-- Yukon Daylight
  • YST-- Yukon Standard
  • ZP4-- USSR Zone 3
  • ZP5-- USSR Zone 4
  • ZP6-- USSR Zone 5

timezone 
(continued)

Relative Time Zones 
The time zone can also be specified as a relative value to one of the supported time zones. The following example would specify Greenwich Mean Time plus eight hours: 
"GMT+0800"User-Defined Time Zones 
You can assign values to the TZ1 and TZ2 time zones by using the AgentSetup/PATROLTZ variable. This variable uses the format REPLACE="TZ1/ offset1 ,TZ2/ offset2 " where offset1and offset2 represent the difference (in minutes) between GMT and the user-defined time zone. 
For example, the following syntax would mean that the first time zone is three hours ahead of GMT while the second time zone is one hour behind GMT: 
REPLACE="TZ1/+180,TZ2/-60"Default 
computer system local time zone

Description

The convert_date() function returns an integer that is the number of seconds past 00:00:00 GMT January 1, 1970 of the specified date and time string. The convert_date() command can parse any of three date and time string formats:

  • RFC-822 format (day, date month year time timezone)
  • Unix format (day month date time timezone year)
  • PSL date() function format (day month date time year)

The convert_date() function requires the timezone parameter to correctly convert the date and time. If timezone is not specified, either in the date and time string (RFC-822 and Unix formats) or as a separate parameter (all formats), the convert_date() function uses the time zone defined for the machine on which it is executing. 

If the convert_date() function encounters an error, it returns a zero and sets the PSL errno variable as follows:

errno Value

Description

111

E_PSL_BAD_DATE_STRING-- indicates that the convert_date() function could not parse the date and time string

112

E_PSL_BAD_TIMEZONE -- indicates that the convert_date() function did not recognize the specified timezone

113

E_PSL_CANNOT_DETERMINE_TIMEZONE -- indicates that the convert_date() function is using timezone = GMT because notimezone was supplied and the time zone used by the system could not be determined

Example

The following convert_date() function calls illustrate the different ways to specify the timezone parameter:

# Specify timezone as part of the date and time string
seconds = convert_date("Fri Mar 8 11:39:07 CST 1996");
print("Converted time is ",seconds,"\n");
# Specify timezone as a separate parameter
seconds = convert_date("Fri Mar 8 11:39:07 1996","CST");
print("Converted time is ",seconds,"\n");
# Use time zone defined in the operating system
seconds = convert_date("Fri Mar 8 11:39:07 1996");
print("Converted time is ",seconds,"\n");

In the case where the operating system uses the CST time zone, the example produces the following output:

Converted time is 826306747
Converted time is 826306747
Converted time is 826306747

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*