Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test functions

check_date_parts()

Description

Check datepart conforms to its formatting and error out each section accordingly

Parameters

ColumnTypeDefaultDescription
$parts
array array of the date parts

Return

string

Location

include/metadata_functions.php lines 234 to 275

Definition

 
function check_date_parts($parts)
    {
    global 
$lang;
    
    
// Initialise error list holder
    
$invalid_parts = array();
    
    
// Check day part
    
if (!checkdate('01',$parts[3],'2000'))
        {
        
array_push($invalid_parts'day');
        } 
    
// Check day month
    
if (!checkdate($parts[2],'01','2000')) 
        {
        
array_push($invalid_parts'month');
        } 
    
// Check year part
    
if (!checkdate('01','01',$parts[1])) 
        {
        
array_push($invalid_parts'year');
        }
    
// Check time part
    
if (
        isset(
$parts[4]) 
        && isset(
$parts[5])
        && !
strtotime($parts[4] . ':' $parts[5])
        ) {
            
array_push($invalid_parts'time');
        }

    
// No errors found return false
    
if(empty($invalid_parts))
        {
        return 
false;
        } 
    
// Return errors found
    
else
        {
        return 
str_replace("%parts%"implode(", "$invalid_parts), $lang["date_format_error"]);
        }
    }

This article was last updated 17th November 2024 15:35 Europe/London time based on the source file dated 6th March 2024 14:45 Europe/London time.