[smartpl] add 'THIS WEEK'
This commit is contained in:
parent
d6a9ef4081
commit
c66df6864c
|
@ -162,9 +162,9 @@ One example of a valid date is a date in yyyy-mm-dd format:
|
|||
```
|
||||
|
||||
There are also some special date keywords:
|
||||
* `today`, `yesterday`, `last week`, `last month`, `last year`
|
||||
* `today`, `yesterday`, `this week`, `last week`, `last month`, `last year`
|
||||
|
||||
These dates refer to the _start_ of that period; `today` means 00:00hrs of today, `last week` means the previous Monday 00:00hrs, `last month` is the first day of the previous month at 00:00hrs etc.
|
||||
These dates refer to the _start_ of that period; `today` means 00:00hrs of today, `this week` means current Monday 00:00hrs, `last week` means the previous Monday 00:00hrs, `last month` is the first day of the previous month at 00:00hrs etc.
|
||||
|
||||
A valid date can also be made by applying an interval to a date. Intervals can be defined as `days`, `weeks`, `months`, `years`.
|
||||
As an example, a valid date might be:
|
||||
|
|
|
@ -122,6 +122,7 @@ limit { return SMARTPL_T_LIMIT; }
|
|||
{yyyymmdd} { yylval->str = strdup(yytext); return SMARTPL_T_DATE; }
|
||||
today { return (yylval->ival = SMARTPL_T_DATE_TODAY); }
|
||||
yesterday { return (yylval->ival = SMARTPL_T_DATE_YESTERDAY); }
|
||||
this\ week { return (yylval->ival = SMARTPL_T_DATE_THISWEEK); }
|
||||
last\ week { return (yylval->ival = SMARTPL_T_DATE_LASTWEEK); }
|
||||
last\ month { return (yylval->ival = SMARTPL_T_DATE_LASTMONTH); }
|
||||
last\ year { return (yylval->ival = SMARTPL_T_DATE_LASTYEAR); }
|
||||
|
|
|
@ -396,6 +396,8 @@ static void sql_from_ast(struct smartpl_result *result, struct result_part *part
|
|||
sql_append_recursive(result, part, a, "now', 'start of day", NULL, 0, SQL_APPEND_DATE_FIELD); break;
|
||||
case SMARTPL_T_DATE_YESTERDAY:
|
||||
sql_append_recursive(result, part, a, "now', 'start of day', '-1 day", NULL, 0, SQL_APPEND_DATE_FIELD); break;
|
||||
case SMARTPL_T_DATE_THISWEEK:
|
||||
sql_append_recursive(result, part, a, "now', 'start of day', 'weekday 0', '-7 days", NULL, 0, SQL_APPEND_DATE_FIELD); break;
|
||||
case SMARTPL_T_DATE_LASTWEEK:
|
||||
sql_append_recursive(result, part, a, "now', 'start of day', 'weekday 0', '-13 days", NULL, 0, SQL_APPEND_DATE_FIELD); break;
|
||||
case SMARTPL_T_DATE_LASTMONTH:
|
||||
|
@ -505,6 +507,7 @@ static int result_set(struct smartpl_result *result, char *title, struct ast *cr
|
|||
%token <str> SMARTPL_T_DATE
|
||||
%token <ival> SMARTPL_T_DATE_TODAY
|
||||
%token <ival> SMARTPL_T_DATE_YESTERDAY
|
||||
%token <ival> SMARTPL_T_DATE_THISWEEK
|
||||
%token <ival> SMARTPL_T_DATE_LASTWEEK
|
||||
%token <ival> SMARTPL_T_DATE_LASTMONTH
|
||||
%token <ival> SMARTPL_T_DATE_LASTYEAR
|
||||
|
@ -592,6 +595,7 @@ dateexpr: SMARTPL_T_DATE { $$ = ast_new(SMART
|
|||
|
||||
daterelative: SMARTPL_T_DATE_TODAY
|
||||
| SMARTPL_T_DATE_YESTERDAY
|
||||
| SMARTPL_T_DATE_THISWEEK
|
||||
| SMARTPL_T_DATE_LASTWEEK
|
||||
| SMARTPL_T_DATE_LASTMONTH
|
||||
| SMARTPL_T_DATE_LASTYEAR
|
||||
|
|
Loading…
Reference in New Issue