“天街小雨润如酥,草色遥看近却无。最是一年春好处,绝胜烟柳满皇都。”读一首古诗,心情也随之平静下来

Lr_save_datetime函数的使用

上一篇 / 下一篇  2008-04-10 09:26:36 / 天气: 晴朗 / 心情: 高兴 / 置顶(1) / 个人分类:测试工具

    最近几天在录制测试脚本,希望能有一个方法自动保存系统时间,以便能够更好的进行分辨,于是在LR的帮助函数中查找到了lr_save_datetime函数,一试验,感觉非常不错,满足了我的要求,下面就将lr_save_datetime函数的使用方法记载下来,以便后用:

 

函数原型:

voidlr_save_datetime(const char *format,intoffset,const char *name);

 

format期望输出的日期格式比如说%Y%m%d%X等等

 

offset:类似与表示时间的一些关键字常量,主要有DATE_NOW, TIME_NOW, ONE_DAY, ONE_HOUR, ONE_MIN,他们可以单独使用,也可以联合使用,比如DATE_NOW + TIME_NOW

 

name:期望将时间保存到的那个参数的名称

 

举例:

lr_save_datetime(%Y-%m-%d %x,DATE_NOW+TIME_NOW,DateTimeParam);

lr_output_message(lr_eval_string("Now is {DateTimeParam}"));

 

format格式参照表:

 

Code

Descrīption

%a

day of week, using locale's abbreviated weekday names

%A

day of week, using locale's full weekday names

%b

month, using locale's abbreviated month names

%B

month, using locale's full month names

%c

date and time as %x %X

%d

day of month (01-31)

%H

hour (00-23)

%I

hour (00-12)

%j

number of day in year (001-366)

%m

month number (01-12)

%M

minute (00-59)

%p

locale's equivalent of AM or PM, whichever is appropriate

%S

seconds (00-59)

%U

week number of year (01-52), Sunday is the first day of the week. Week number 01 is the first week with four or more January days in it.

%w

day of week; Sunday is day 0

%W

week number of year (01-52), Monday is the first day of the week. Week number 01 is the first week with four or more January days in it.

%x

date, using locale's date format

%X

time, using locale's time format

%y

year within century (00-99)

%Y

year, including century (for example, 1988)

%Z

time zone abbreviation

%%

to include the "%" character in your output string

 


TAG: Lr_save_datetime 测试工具

 

评分:0

我来说两句

Open Toolbar