root

Changeset 476

Show
Ignore:
Timestamp:
01/11/09 23:20:07 (2 years ago)
Author:
wbond
Message:

Added support for CURRENT_TIMESTAMP, CURRENT_DATE and CURRENT_TIME SQL keywords to fDate, fTime and fTimestamp as appropriate

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • fDate.php

    r457 r476 Hide Line Numbers
    33 * Represents a date as a value object 
    44 *  
    5  * @copyright  Copyright (c) 2008 Will Bond 
     5 * @copyright  Copyright (c) 2008-2009 Will Bond 
    66 * @author     Will Bond [wb] <will@flourishlib.com> 
    77 * @license    http://flourishlib.com/license 
     
    1010 * @link       http://flourishlib.com/fDate 
    1111 *  
    12  * @version    1.0.0b2 
     12 * @version    1.0.0b3 
     13 * @changes    1.0.0b3  Added support for CURRENT_TIMESTAMP and CURRENT_DATE SQL keywords [wb, 2009-01-11] 
    1314 * @changes    1.0.0b2  Removed the adjustment amount check from ::adjust() [wb, 2008-12-31] 
    1415 * @changes    1.0.0b   The initial implementation [wb, 2008-02-10] 
     
    6162        } elseif (is_numeric($date) && ctype_digit($date)) { 
    6263            $timestamp = (int) $date; 
     64        } elseif (is_string($date) && in_array(strtoupper($date), array('CURRENT_TIMESTAMP', 'CURRENT_DATE'))) { 
     65            $timestamp = time(); 
    6366        } else { 
    6467            if (is_object($date) && is_callable(array($date, '__toString'))) { 
     
    284287 
    285288/** 
    286  * Copyright (c) 2008 Will Bond <will@flourishlib.com> 
     289 * Copyright (c) 2008-2009 Will Bond <will@flourishlib.com> 
    287290 *  
    288291 * Permission is hereby granted, free of charge, to any person obtaining a copy 
  • fTime.php

    r457 r476 Hide Line Numbers
    33 * Represents a time of day as a value object 
    44 *  
    5  * @copyright  Copyright (c) 2008 Will Bond 
     5 * @copyright  Copyright (c) 2008-2009 Will Bond 
    66 * @author     Will Bond [wb] <will@flourishlib.com> 
    77 * @license    http://flourishlib.com/license 
     
    1010 * @link       http://flourishlib.com/fTime 
    1111 *  
    12  * @version    1.0.0b2 
     12 * @version    1.0.0b3 
     13 * @changes    1.0.0b3  Added support for CURRENT_TIMESTAMP and CURRENT_TIME SQL keywords [wb, 2009-01-11] 
    1314 * @changes    1.0.0b2  Removed the adjustment amount check from ::adjust() [wb, 2008-12-31] 
    1415 * @changes    1.0.0b   The initial implementation [wb, 2008-02-12] 
     
    6162        } elseif (is_numeric($time) && ctype_digit($time)) { 
    6263            $timestamp = (int) $time; 
     64        } elseif (is_string($time) && in_array(strtoupper($time), array('CURRENT_TIMESTAMP', 'CURRENT_TIME'))) { 
     65            $timestamp = time(); 
    6366        } else { 
    6467            if (is_object($time) && is_callable(array($time, '__toString'))) { 
     
    275278 
    276279/** 
    277  * Copyright (c) 2008 Will Bond <will@flourishlib.com> 
     280 * Copyright (c) 2008-2009 Will Bond <will@flourishlib.com> 
    278281 *  
    279282 * Permission is hereby granted, free of charge, to any person obtaining a copy 
  • fTimestamp.php

    r451 r476 Hide Line Numbers
    33 * Represents a date and time as a value object 
    44 *  
    5  * @copyright  Copyright (c) 2008 Will Bond 
     5 * @copyright  Copyright (c) 2008-2009 Will Bond 
    66 * @author     Will Bond [wb] <will@flourishlib.com> 
    77 * @license    http://flourishlib.com/license 
     
    1010 * @link       http://flourishlib.com/fTimestamp 
    1111 *  
    12  * @version    1.0.0b 
    13  * @changes    1.0.0b  The initial implementation [wb, 2008-02-12] 
     12 * @version    1.0.0b2 
     13 * @changes    1.0.0b2  Added support for CURRENT_TIMESTAMP, CURRENT_DATE and CURRENT_TIME SQL keywords [wb, 2009-01-11] 
     14 * @changes    1.0.0b   The initial implementation [wb, 2008-02-12] 
    1415 */ 
    1516class fTimestamp 
     
    746747        } elseif (is_numeric($datetime) && ctype_digit($datetime)) { 
    747748            $timestamp = (int) $datetime; 
     749        } elseif (is_string($datetime) && in_array(strtoupper($datetime), array('CURRENT_TIMESTAMP', 'CURRENT_TIME'))) { 
     750            $timestamp = time(); 
     751        } elseif (is_string($datetime) && strtoupper($datetime) == 'CURRENT_DATE') { 
     752            $timestamp = strtotime(date('Y-m-d')); 
    748753        } else { 
    749754            if (is_object($datetime) && is_callable(array($datetime, '__toString'))) { 
     
    988993 
    989994/** 
    990  * Copyright (c) 2008 Will Bond <will@flourishlib.com> 
     995 * Copyright (c) 2008-2009 Will Bond <will@flourishlib.com> 
    991996 *  
    992997 * Permission is hereby granted, free of charge, to any person obtaining a copy