Skip to content

Commit 53f07d5

Browse files
committed
Add hour, minute and second parser; Add this, next, last parser for hour, minute and second
1 parent ee41586 commit 53f07d5

File tree

8 files changed

+2107
-146
lines changed

8 files changed

+2107
-146
lines changed

README.md

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# PHP Date Parser
22

3-
This library parses different strings to DateTime or DateTimeImmutable classes.
4-
Can be used e.g. excellently for command line arguments and options.
3+
This library parses various given date and time strings into
4+
DateTime or DateTimeImmutable classes which return the time
5+
range. Can be used e.g. excellently for command line
6+
arguments and options to make database queries with.
57

68
## Installation
79

@@ -57,17 +59,26 @@ $dateParser = (new DateParser('<2023-07-01', 'America/New_York'))->formatTo('Y-m
5759
5860
### Supported words
5961
60-
| Word | Description |
61-
|--------------|-------------------------------|
62-
| `tomorrow` | The day tomorrow (`'j' + 1`) |
63-
| `today` | The day today (`'j'`) |
64-
| `yesterday` | The day yesterday (`'j' - 1`) |
65-
| `next-month` | Next month (`'n' + 1`) |
66-
| `this-month` | This month (`'n'`) |
67-
| `last-month` | Last month (`'n' - 1`) |
68-
| `next-year` | Next year (`'Y' + 1`) |
69-
| `this-year` | This year (`'Y'`) |
70-
| `last-year` | Last year (`'Y' - 1`) |
62+
| Word | Description |
63+
|---------------|-------------------------------|
64+
| `next-second` | Next second (`'s' + 1`) |
65+
| `this-second` | This second (`'s'`) |
66+
| `last-second` | Last second (`'s' - 1`) |
67+
| `next-minute` | Next minute (`'i' + 1`) |
68+
| `this-minute` | This minute (`'i'`) |
69+
| `last-minute` | Last minute (`'i' - 1`) |
70+
| `next-hour` | Next hour (`'G' + 1`) |
71+
| `this-hour` | This hour (`'G'`) |
72+
| `last-hour` | Last hour (`'G' - 1`) |
73+
| `tomorrow` | The day tomorrow (`'j' + 1`) |
74+
| `today` | The day today (`'j'`) |
75+
| `yesterday` | The day yesterday (`'j' - 1`) |
76+
| `next-month` | Next month (`'n' + 1`) |
77+
| `this-month` | This month (`'n'`) |
78+
| `last-month` | Last month (`'n' - 1`) |
79+
| `next-year` | Next year (`'Y' + 1`) |
80+
| `this-year` | This year (`'Y'`) |
81+
| `last-year` | Last year (`'Y' - 1`) |
7182
7283
### Overview
7384

bin/header/phpmd

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
3+
# ------------
4+
# This script prints the header for PHPMND - PHP Magic Number Detector
5+
#
6+
# @author Björn Hempel <bjoern@hempel.li>
7+
# @version 0.1.0 (2022-12-18)
8+
# ------------
9+
10+
HEADER="PHPMD - PHP Mess Detector"
11+
COMMAND="$1"
12+
DESCRIPTION="$2"
13+
14+
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
15+
16+
eval "$SCRIPT_DIR/global \"$HEADER\" \"$COMMAND\" \"$DESCRIPTION\" \"$DESCRIPTION\""
17+
RETURN_CODE=$?
18+
19+
exit $RETURN_CODE
20+

composer.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"name": "ixnode/php-date-parser",
3-
"description": "PHP Date Parser - This library parses different strings to DateTime or DateTimeImmutable classes.",
3+
"description": "PHP Date Parser - This library parses various given date and time strings into DateTime or DateTimeImmutable classes which return the time range. Can be used e.g. excellently for command line arguments and options to make database queries with.",
44
"type": "library",
55
"license": "MIT",
6-
"keywords": ["php", "date", "parser", "conversion"],
6+
"keywords": ["php", "date", "time", "parser", "conversion", "DateTime", "DateTimeImmutable"],
77
"authors": [
88
{
99
"name": "Björn Hempel",
@@ -22,7 +22,8 @@
2222
}
2323
},
2424
"require": {
25-
"php": "^8.2"
25+
"php": "^8.2",
26+
"ixnode/php-naming-conventions": "^0.1.1"
2627
},
2728
"require-dev": {
2829
"phpunit/phpunit": "^9.5",
@@ -44,7 +45,7 @@
4445
"@phpmnd:all"
4546
],
4647

47-
"phpmd": "bin/header/phpmnd 'phpmd src,tests text cleancode,codesize,controversial,design,naming,unusedcode' 'all'",
48+
"phpmd": "bin/header/phpmd 'phpmd src,tests text cleancode,codesize,controversial,design,naming,unusedcode' 'all'",
4849

4950
"phpunit": "bin/header/phpunit 'phpunit --stop-on-failure tests' 'Unit'",
5051

composer.lock

Lines changed: 60 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)