Who to use policy operator $DATETIME

Hey everyone,

I'm having simple question. In the policies there is this operator we could use to format datetimes.

In the docs it just says this:

  • <$DATETIME(FORMAT,VALUE)>, to convert the format of dates from the common format to the UNIX systems time (Epoch time) format.


So value would be my variable, but what is format? The format of my input? Shouldn't that be recognized anyways?
And also the field in the policy says its the other way round?!

So whatever comes first if I'm having a date like that "2024-06-20 07:21:20" would it then be 
"<$DATETIME(<$DATA:datetime>,yyyy-mm-dd hh:mm:ss)>"?

It's very confusing because the $MATCH operator mentioned above is used differently as it is just triggered with $MATCH and then the variables are used. Why is $DATETIME triggerd within the <> brackets?

  • 0  

    Hello,

    I think it’s best documented here https://docs.microfocus.com/doc/Operations_Connector/2019.05/policies/web_service/ws_rules_events, which is better than https://docs.microfocus.com/doc/Operations_Bridge_Manager/2023.05/OmucptrestWebservicehtml.

      

     

    Date and time when the event was created.

    Use the following conventions when specifying the date and time attribute:

    • Integers.Operations Connector interprets integers in the policy source as seconds since 00:00:00 UTC on 1 January 1970 (UNIX system time). For example, 1276600333 is 15 June 2010, at 11:12:13.
    • Default time formats.Operations Connector by default interprets the following time formats:

    yyyy-mm-ddTHH:MM:SS (for example, 2010-06-15T11:12:13)

    mm/dd/yyyy HH:MM:SS (for example, 06/15/2010 11:12:13)

    Additional time zone formats are supported:

    yyyy-mm-ddTHH:MM:SS tz (for example, 2010-06-15T11:12:13 +3)

    mm/dd/yyyy HH:MM:SS tz(for example, 06/15/2010 11:12:13 -2)

    where tz is a number for the offsett to the UTC time zone. You can also use half or quarter hours (.25, .5, or .75, for example, 2010-06-15T11:12:13 -2.75).

    If you want to create your own pattern, you can store the time zone information in <@.tz> to match all above mentioned time zones.

    • Pattern matching. You can use the function <$DATETIME(FORMAT,VALUE)> to specify a pattern (FORMAT) that matches the time string in the policy source (VALUE). You can use standard pattern-matching rules when matching values. By default, pattern matching for the time format is case sensitive. The default field separators are the space and the tab characters.

    FORMAT must be enclosed in quotation marks ("FORMAT") and accepts the following variables:

    H (hours), M (minutes), S (seconds). If H, M, or S is not set, the hour, minute, or second displays as zero.

    d (day), m (month), y (year). If d or m is not set, the day or month display as one. If y is not set, the current year is assumed. If y is less than 100, the current millennium is assumed; for example, if y matches 10, the year displays as 2010. It is not possible to match a year earlier than 1970.

    p (P.M.) If p is set, Operations Connector adds 12 hours to the hours that precede the variable.

    VALUE is the XML property to match.

    XML properties use the following syntax: <$DATA:/BSMConnectorEvent/<XML property>>

    <XML property> is the string assigned to the XML property from the XML event tag (for example, <severity>Warning</severity>)

    Examples:

    To match the time format 06/15/2010 11:12:13 in the pattern matching field <$DATA:timestamp>, type
    <$DATETIME("^<#.m>/<#.d>/<#.y> <#.H>:<#.M>:<#.S>$",<$DATA:timestamp>)>

    To match the time format 11:12 15.06.2010 in the pattern matching field <$DATA:timestamp>, type
    <$DATETIME("^<#.H>:<#.M> <#.d>.<#.m>.<#.y>$",<$DATA:timestamp>)>

    To match the time format 06/15/2010 1:35 PM in the pattern matching field <$DATA:timestamp>, type
    <$DATETIME("^<#.m>/<#.d>/<#.y> <#.H>:<#.M> <2*.p>$",<$DATA:timestamp>)>

    To match the time format 06/15/2010 11:12:13 in the XML property <$DATA:/BSMCEvent/timeStamp>, type
    <$DATETIME("^<#.m>/<#.d>/<#.y> <#.H>:<#.M>:<#.S>$",<$DATA:/BSMCEvent/timeStamp>)>

    To match the time format 11:12 15.06.2010 in the XML property <$DATA:/BSMCEvent/timeStamp>, type
    <$DATETIME("^<#.H>:<#.M> <#.d>.<#.m>.<#.y>$",<$DATA:/BSMCEvent/timeStamp>)>

    To match the time format 06/15/2010 1:35 PM in the XML property <$DATA:/BSMCEvent/timeStamp>, type
    <$DATETIME("^<#.m>/<#.d>/<#.y> <#.H>:<#.M> <2*.p>$",<$DATA:/BSMCEvent/timeStamp>)>

    If you leave the attribute empty or if none of the time formats above can be matched, then the date and time when the agent created the event appears in OBM. This time always appears using the time zone of the agent at creation time (for example, 11:30 (CET/winter). This means that this time always appears in this fixed time zone.

     

    I hope that helps.  

  • 0

    Hey Duncan,
    thanks for the answer. 
    This document is so old, WOW. Why couldn't they just put it in the docs? 
    Nevertheless, I tried it as mentioned there, but it didn't work :( 

    I will open a case at Opentext - they must have a documentation somewhere ... hopefully