Start a Conversation

This post is more than 5 years old

Solved!

Go to Solution

4279

May 29th, 2017 01:00

How to compare two time values in asl script

Hi,

Any body can guide how two values of time can be compared using ASL script I have used this code but somehow its not working

if(time() > time(1496061600)){

print(time()." Is Greater than ".time(1496061600));}

I have tried this comparison in different ways by even converting it to numeric value but it is not working.

July 4th, 2017 02:00

START {

.. eol

}

do {

p = time();

r = numeric(p);

q = time(1496061600);

//print(p);

//print(q);

//print("the numeric time for Today is ".r);

if (r > q){

print(r."value is greater than".q);

}

}

output:

1499161207value is greater than1496061600

54 Posts

June 27th, 2017 15:00

Thank you for contacting the Dell EMC Community Network.

That is a great question and I'm researching your issue and will followup with you on Thursday.

Kind Regards,


Sean

June 27th, 2017 21:00

Superbly insufficient setup, background and purpose in relationship to the issue submitted as a question. 

54 Posts

June 29th, 2017 09:00

Nukhanpk,

Can you try the following:

START { } do {

if (time() > time(1496061345)) {

print(time()." Is Greater than ".time(1496061345));

}

stop();

}

just create local/rules/test_time.asl and add the above, then run with sm_adatper test_time.asl



Please let me know if this helps.


14 Posts

June 30th, 2017 01:00

Dear Sean,

I have executed the script and following is the error output for your reference:

[June 30, 2017 12:15:28 PM GMT+05:00 +344ms] t@978790176 adapter

ASL-E-ERROR_RULE_INIT-While initializing rule set

ASL-ERROR_FILE_PARSE-While parsing rules in file 'test_time.asl'

ASL-ERROR_NO_START-Start rule is missing

[June 30, 2017 12:15:28 PM GMT+05:00 +360ms] t@978790176 adapter

SVIF-N-SHUTDOWN-Shutting down...

5 Practitioner

 • 

274.2K Posts

June 30th, 2017 10:00

Hello Nukhanpk,

The provided script works in Dell-EMC labs. Could you verify what command you are using to run the script and also upload the script from your environment to the post to be validated. 

14 Posts

July 1st, 2017 23:00

Dear Lisa,

Smarts version 9.2.4 is being used here and I am using this logic actually to restrict email adapter to send emails based of specific time value (say only between 9:00 am to 06:00 pm). I used other logics in the ASL script by using different classes and their values and it working fine but some how time values and their comparison is not working.

following is the ASL script which i am using for test with sm_adapter.


START { } do {

//comparing June 30, 2017 12:15:28 PM GMT+05:00 +344ms with 09:00 am

if (time() > time(1498813200)) {

print(time()." Is Greater than ".time(1498813200));

}

stop();

}

after executing I receive following error:

[June 30, 2017 12:15:28 PM GMT+05:00 +344ms] t@978790176 adapter

ASL-E-ERROR_RULE_INIT-While initializing rule set

ASL-ERROR_FILE_PARSE-While parsing rules in file 'test_time.asl'

ASL-ERROR_NO_START-Start rule is missing

[June 30, 2017 12:15:28 PM GMT+05:00 +360ms] t@978790176 adapter

SVIF-N-SHUTDOWN-Shutting down...

July 2nd, 2017 13:00

Hi Lisa.  Hope you are well.  Happy 4th of July!

Dave Redwine

54 Posts

July 7th, 2017 08:00

Nukhanpk,


Just asking if any of the provided answers have resolved your issue?


Please let me know.


Kind Regards,


Sean

July 7th, 2017 08:00

Hii sean,

Yes, It had resolved our issue.

14 Posts

July 17th, 2017 00:00

Dear Prashanth,

        Thanks for your solution its working perfectly, can you help me to make it more better as I want to compare value of current time in numeric with the value of some specific time value of same day. I mean its actually a mail adapter which I am customizing to stop email sending if time is more than 18:00 hours of the same day when mail is being sent.

In a nutshell is there any way to convert  say [ July 18, 2017 4:00:00 AM GMT+05:00] to numeric in order to compare it with the numeric value current time stamp (numeric(time())).

14 Posts

July 17th, 2017 03:00

Dear Sean,

     The answer provided by Prashanth is working but I am having some difficulty matching event time with specific time of the day say 18:00 and unable to find any function which will 18th hour of the day in which event has occurred.

time() function only converts numeric value to string time but I can not find any function which can return hour of today.

54 Posts

July 18th, 2017 13:00

Nukhanpk,

We are researching your question and will followup with you on Friday.

Kind Regards,


Sean

July 19th, 2017 04:00

START {

.. eol

}

do {

p = time();

r = numeric(p);

print(r);

// Use the sleep function to specify the Time lapse for the next numeric time to be passed

// For Example to specify the Time period of 18 Hours

// Pass it as sleep(64800); for the next required time to be recorded and stop the adapter after the time lapse

// sleep function for 1 Hour

sleep(3600);

m = time();

n = numeric(m);

q = time(1496061600);

//print(p);

//print(q);

//print("the numeric time for Today is ".r);

if (n > r){

print(n."value is greater than".r);

}

}

July 19th, 2017 10:00

You guys crack me up.  Why in the world would you spent 2 months worth of back and forth messaging working on an ASL solution to a problem you could have solved in 30 minutes with an escalation policy, a cronjob and a shell script with DMCTL?  I guess when all you know is how to use a hammer, every problem looks like a nail.

No Events found!

Top