Strings
[ class tree: Strings ] [ index: Strings ] [ all elements ]

Class: STRdates

Source Location: /STRdates.php

Class Overview

Strings
   |
   --STRdates

This class manages STRdates objects. It is used to manipulate dates strings.


Author(s):

Version:

  • 2.2

Variables

Methods


Inherited Variables

Inherited Methods

Class: Strings

Strings::__construct()
Construction function
Strings::console()
Console function
Strings::IsUTF8()
UTF8 detection function
Strings::QuoteStrip()
Quotes stripping function
Strings::RemoveAccent()
Accents removal function
Strings::RemoveSpaces()
Spaces removal function
Strings::stringHasNumbers()
Numbers detection function
Strings::ToUTF8()
UTF8 conversion function
Strings::ucwordsw()
Special uppercase function

Class Details

[line 40]
This class manages STRdates objects. It is used to manipulate dates strings.

Created on 05 sep 06

Changes: 2.1 -> 2.2: 27 jul 09 updated: file is PEAR compatible name of class has been changed from Dates to STRdates 2.0 -> 2.1: updated: ListHours() and ListMinutes() functions have been deprecated -> STRtimes::listHours(), STRtimes::listMinutes() 1.0 -> 2.0: updated: phpdoc compatible in the way to generate documentation




Tags:



[ Top ]


Class Variables

$date_ts =  0

[line 52]

Variable that defines date timestamp



Tags:

access:  public

Type:   int


[ Top ]

$DMY_regex =  '/(\d{1,2})\D(\d{1,2})\D(\d{1,4})/si'

[line 83]

Variable that defines regular expression used to extract Day, Month,

Year




Tags:

access:  protected

Type:   string


[ Top ]

$months_array = array(
        1   =>  "Jan",
        2   =>  "Feb",
        3   =>  "Mar",
        4   =>  "Apr",
        5   =>  "May",
        6   =>  "Jun",
        7   =>  "Jul",
        8   =>  "Aug",
        9   =>  "Sep",
        10  =>  "Oct",
        11  =>  "Nov",
        12  =>  "Dec"
    )

[line 58]

Variable that defines months in an associative array



Tags:

access:  protected

Type:   array


[ Top ]

$new_separator =  "-"

[line 46]

Variable that defines date separator



Tags:

access:  public

Type:   string


[ Top ]

$YMD_regex =  '/(\d{1,4})\D(\d{1,2})\D(\d{1,2})/si'

[line 77]

Variable that defines regular expression used to extract Year, Month,

Day




Tags:

access:  protected

Type:   string


[ Top ]



Class Methods


method check [line 113]

bool check( [bool $passed = false], string $this->value)

Y-M-D date validation function

This function is used to valid a Y-M-D date Result is returned

  1.  <?php
  2.  $oDates            new STRdates();
  3.  $oDates->value    "2009-01-01";
  4.  echo $oDates->check();
  5.  // 1
  6.  ?>




Tags:

return:  true if date is valid
since:  version 1.0


Parameters:

string   $this->value   date string to be processed (required)
bool   $passed   if set to true, the date must be in the past

[ Top ]

method checkYear [line 183]

bool checkYear( [bool $passed = true], [bool $rangemin = 1900], [bool $rangemax = 2030], string $this->value)

Year validation function

This function is used to valid a year Result is returned

  1.  <?php
  2.  $oDates        new STRdates();
  3.  $oDates->value "1229";
  4.  echo $oDates->checkYear(
  5.       false,
  6.       1500,
  7.       2000
  8.  );
  9.  // 0
  10.  ?>




Tags:

return:  true if year is valid
since:  version 1.0


Parameters:

string   $this->value   year string to be processed (required)
bool   $passed   if set to true, the date must be in the past
bool   $rangemin   minimal value for the year
bool   $rangemax   maximal value for the year

[ Top ]

method convert [line 231]

string convert( string $this->value, string $this->new_separator)

Date convertion function

This function is used to convert a Y-M-D date to a D-M-Y date Result is returned

  1.  <?php
  2.  $oDates        new STRdates();
  3.  $oDates->value "2009-02-23";
  4.  echo $oDates->convert();
  5.  // 23-02-2009
  6.  ?>




Tags:

return:  converted date
staticvar:  string $this->YMD_regex: regular expression used to parse date
since:  version 1.0


Parameters:

string   $this->value   date string to be processed (required)
string   $this->new_separator   separator to use for the new date format

[ Top ]

method Convert2TS [line 691]

int Convert2TS( int $this->value)

Date convertion to timestamp function

This function is used to convert a date to a timestamp Result is stored in $this->value and returned

  1.  <?php
  2.  $oDates            new STRdates("25.12.1982");
  3.  echo $oDates->Convert2TS();
  4.  // 409618800
  5.  ?>




Tags:

return:  timestamp of the specified date string
staticvar:  string $this->DMY_regex: regular expression defining a DMY date format
staticvar:  string $this->YMD_regex: regular expression defining a YMD date format
since:  version 1.0
uses:  STRdates::ConvertDMY2YMD()


Parameters:

int   $this->value   date string to be treated

[ Top ]

method convertDMY2YMD [line 277]

string convertDMY2YMD( string $this->value, string $this->new_separator)

Date convertion (DMY -> YMD) function

This function is used to convert a D-M-Y date to a Y-M-D date Result is returned

  1.  <?php
  2.  $oDates            new STRdates();
  3.  $oDates->value    "23-02-2009";
  4.  echo $oDates->convertDMY2YMD();
  5.  // 2009-02-23
  6.  ?>




Tags:

return:  converted date
staticvar:  string $this->DMY_regex: regular expression used to parse date
since:  version 1.0
usedby:  STRlines::formatLine()


Parameters:

string   $this->value   date string to be processed (required)
string   $this->new_separator   separator to use for the new date format

[ Top ]

method is_ddmmyyyy [line 652]

bool is_ddmmyyyy( int $this->value)

ddmmyyyy format detection function

This function is used to check if value is a dd-mm-yyyy date Result is returned

  1.  <?php
  2.  $oDates            new STRdates("25.12.1982");
  3.  echo $oDates->is_ddmmyyyy();
  4.  // 1
  5.  ?>




Tags:

return:  true if the value is a ddmmyyyy date
staticvar:  string $this->DMY_regex: regular expression defining a DMY date format
since:  version 1.0


Parameters:

int   $this->value   date string to be treated

[ Top ]

method ListAll [line 588]

array ListAll( [int $fromyear = 0], [int $toyear = 1])

Years, Months, Days, Hours, Minutes listing function

This function is used to list Years, Months, Days, Hours, Minutes Result is returned

  1.  <?php
  2.  $oDates            new STRdates();
  3.  $result            $oDates->ListAll();
  4.  print_r($result["msg"]);
  5.  // years, months, days, hours, minutes array
  6.  ?>




Tags:

return:  Years, Months, Days, Hours, Minutes listing
since:  version 1.0
uses:  STRtimes::listMinutes()
uses:  STRtimes::listHours()
uses:  STRdates::ListMonths()
uses:  STRdates::ListDays()
uses:  STRdates::ListYears()


Parameters:

int   $fromyear   year from which the array will start
int   $toyear   year to which the array will end

[ Top ]

method ListDays [line 481]

array ListDays( )

Days listing function

This function is used to list numeric days of a month Result is returned

  1.  <?php
  2.  $oDates           new STRdates();
  3.  echo implode(" "$oDates->ListDays());
  4.  // 1 2 3 4 5 6 7 8 9 10 11 12... 31
  5.  ?>




Tags:

return:  days listing
since:  version 1.0
usedby:  STRdates::ListAll()


[ Top ]

method ListHours [line 517]

array ListHours( )

Hours listing function

This function is used to list hours of a day Result is returned

  1.  <?php
  2.  $oDates            new STRdates();
  3.  echo implode(" "$oDates->ListHours());
  4.  // 1 2 3 4 5 6 7 8 9 10 11 12... 23
  5.  ?>




Tags:

return:  hours listing
deprecated:  
since:  Version 1.0
uses:  STRtimes::listHours()


[ Top ]

method ListMinutes [line 549]

array ListMinutes( )

Minutes listing function

This function is used to list minutes of an hour Result is returned

  1.  <?php
  2.  $oDates            new STRdates();
  3.  echo implode(" "$oDates->ListMinutes());
  4.  // 01 02 03 04 05 06 07 08 09 10 11 12... 59
  5.  ?>




Tags:

return:  minutes listing
deprecated:  
since:  version 1.0
uses:  STRtimes::listMinutes()


[ Top ]

method ListMonths [line 447]

array ListMonths( )

Months listing function

This function is used to list numeric months Result is returned

  1.  <?php
  2.  $oDates            new STRdates();
  3.  echo implode(" "$oDates->ListMonths());
  4.  // 1 2 3 4 5 6 7 8 9 10 11 12
  5.  ?>




Tags:

return:  months listing
since:  version 1.0
usedby:  STRdates::ListAll()


[ Top ]

method ListYears [line 391]

array ListYears( [string $fromyear = 0], [string $toyear = 1])

Year listing function

This function is used to list years from a specified year to another one Result is returned

  1.  <?php
  2.  $oDates          new STRdates();
  3.  echo implode(" ",$oDates->ListYears());
  4.  // actualyear+10 actualyear+9 actualyear+8... actualyear-90
  5.  ?>




Tags:

return:  year listing
since:  version 1.0
usedby:  STRdates::ListAll()


Parameters:

string   $fromyear   year from which the array will begin
string   $toyear   year to which the array will end

[ Top ]

method quarterBeginTS [line 749]

int quarterBeginTS( int $this->value)

First date of quarter obtention function

This function is used to get the first date of a quarter Result is stored in $this->date_ts and returned

  1.  <?php
  2.  $oDates            new STRdates("03.02.1975");
  3.  echo $oDates->quarterBeginTS();
  4.  // 157762800
  5.  ?>




Tags:

return:  timestamp of the first date of the quarter
since:  version 1.0
usedby:  Exchange_Rates::maxminLastQuarter()
usedby:  Exchange_Rates::avgEndLastQuarter()


Parameters:

int   $this->value   date string to be treated

[ Top ]

method Text2Date [line 321]

string Text2Date( string $this->value)

Date convertion (text) function

This function is used to convert a mmm dd, yyyy date in Y-M-D format Result is returned

  1.  <?php
  2.  $oDates        new STRdates();
  3.  $oDates->value "Feb 03, 2009";
  4.  echo $oDates->Text2Date();
  5.  // 2009-02-03
  6.  ?>




Tags:

return:  converted date
staticvar:  string $this->months_array: associative array of months
since:  version 1.0


Parameters:

string   $this->value   date string to be processed (required)

[ Top ]


Documentation generated on Wed, 26 Aug 2009 12:30:44 +0200 by phpDocumentor 1.4.1