| 1 | package Jifty::DBI::Filter::Date; | ||
| 2 | |||
| 3 | 3 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 3 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 3 | ▶ | use base qw|Jifty::DBI::Filter::DateTime|; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | |||
| 8 | 3 | ▶ | use constant _time_zone => 'floating'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | 3 | ▶ | use constant _strptime => '%Y-%m-%d'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | 3 | ▶ | use constant date_only => 1; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | |||
| 12 | =head1 NAME | ||
| 13 | |||
| 14 | Jifty::DBI::Filter::Date - DateTime object wrapper around date columns | ||
| 15 | |||
| 16 | =head1 DESCRIPTION | ||
| 17 | |||
| 18 | This filter allow you to work with DateTime objects that represent "Dates", | ||
| 19 | store everything in the database in GMT and not hurt yourself badly | ||
| 20 | when you pull them out and put them in repeatedly. | ||
| 21 | |||
| 22 | =head2 encode | ||
| 23 | |||
| 24 | If value is a DateTime object then move it into a "floating" timezone | ||
| 25 | and expand it into ISO 8601 format C<YYYY-MM-DD>. By storing it in | ||
| 26 | the database as a floating timezone, it doesn't matter if the user's | ||
| 27 | desired timezone changes between lookups | ||
| 28 | |||
| 29 | Does nothing if value is not defined or is a string. | ||
| 30 | |||
| 31 | =cut | ||
| 32 | |||
| 33 | =head2 decode | ||
| 34 | |||
| 35 | If we're loading something from a column that doesn't specify times, then | ||
| 36 | it's loaded into a floating timezone. | ||
| 37 | |||
| 38 | If value is defined then converts it into DateTime object otherwise do | ||
| 39 | nothing. | ||
| 40 | |||
| 41 | =cut | ||
| 42 | |||
| 43 | |||
| 44 | =head1 SEE ALSO | ||
| 45 | |||
| 46 | L<Jifty::DBI::Filter>, L<DateTime> | ||
| 47 | |||
| 48 | =cut | ||
| 49 | |||
| 50 | 3 | 1; | |