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