Add colon in timezone format with C

Viewed 75

I want to print the date time in LoadRunner using C language. Currently this is what I have.

Action()
{
    lr_save_datetime("%Y-%m-%dT%H:%M:%S%z", DATE_NOW, "curr_dtm");
    // this is -> 2022-03-08T10:25:09+0800

    lr_output_message(lr_eval_string("{curr_dtm}"));
    
    return 0;
}

I want it to be like 2022-03-08T10:06:47+08:00 where the timezone has colon.

1 Answers

OK. You have a string with everything except the colon. You have a substring of the first n-2 characters which are correct. You need to append another string to this substring with a ':00'

Use the standard C string processing functions to cut out the substring which is correct, append a string in the format you want, and save that to a new string. Exercise those C programming skills!

Related