Name Directory Using Date and Time

scrapefun

A-Parser Enterprise License
A-Parser Enterprise
Currently I create a result directory for every 2000 queries like this:

Code:
[% IF p1.info.success == 1;
           USE Math;
        dir = Math.int(query.num / 2000);
    'test_raw_single/us_' _ dir _ '/' _ query.gl _ '_' _ query.hl _ '_' _ query.id _ '.html';
END %]

This will create directories like:

us_0
us_1
us_2
etc


How would I create directories using the date and time like:

YYYY-MM-DD-H-M-S


I can use the datefile.format() value but that creates a new directory for every query. I want to create a new directory every 2000 queries using the data and time the folder is created.

Is this or something similar possible?
 
Try this:
Code:
[% USE d = date(format = '%Y-%m-%d-%H-%M-%S', locale = 'C');

IF lines % 2000 == 0;
    dir = d.format();
END;

lines = lines + 1;

'test_raw_single/us_' _ dir _ '/' _ query.gl _ '_' _ query.hl _ '_' _ query.id _ '.html' %]
 
Back
Top