created
This commit is contained in:
parent
f213c08ae5
commit
0764960606
|
@ -0,0 +1 @@
|
||||||
|
vendor
|
20
README.md
20
README.md
|
@ -1,3 +1,19 @@
|
||||||
# time
|
# Time
|
||||||
|
Time since Svoboda was created<br>
|
||||||
|
|
||||||
Time since Svoboda was created
|
## Dependencies
|
||||||
|
1. [PHP 8.4](https://www.php.net/releases/8.4/en.php)
|
||||||
|
2. [Composer](https://getcomposer.org/) (php package manager)
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
`composer require svoboda/time`
|
||||||
|
|
||||||
|
## Example
|
||||||
|
```php
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use svoboda\time\statement as svoboda;
|
||||||
|
|
||||||
|
var_dump(svoboda::timestamp());
|
||||||
|
?>
|
||||||
|
```
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
{
|
||||||
|
"name": "svoboda/time",
|
||||||
|
"description": "Time since Svoboda was created",
|
||||||
|
"homepage": "https://git.svoboda.works/svoboda/time",
|
||||||
|
"type": "library",
|
||||||
|
"readme": "README.md",
|
||||||
|
"license": "WTFPL",
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Arsen Mirzaev Tatyano-Muradovich",
|
||||||
|
"email": "arsen@mirzaev.sexy",
|
||||||
|
"homepage": "https://mirzaev.sexy",
|
||||||
|
"role": "Programmer"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"require": {
|
||||||
|
"php": "^8.4"
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"svoboda\\time\\": "svoboda/time/system"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload-dev": {
|
||||||
|
"psr-4": {
|
||||||
|
"svoboda\\time\\tests\\": "svoboda/time/tests"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
{
|
||||||
|
"_readme": [
|
||||||
|
"This file locks the dependencies of your project to a known state",
|
||||||
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
|
"This file is @generated automatically"
|
||||||
|
],
|
||||||
|
"content-hash": "747a4e9f0ccecc15e0c895de6ed5fed3",
|
||||||
|
"packages": [],
|
||||||
|
"packages-dev": [],
|
||||||
|
"aliases": [],
|
||||||
|
"minimum-stability": "stable",
|
||||||
|
"stability-flags": {},
|
||||||
|
"prefer-stable": false,
|
||||||
|
"prefer-lowest": false,
|
||||||
|
"platform": {
|
||||||
|
"php": "^8.4"
|
||||||
|
},
|
||||||
|
"platform-dev": {},
|
||||||
|
"plugin-api-version": "2.6.0"
|
||||||
|
}
|
|
@ -0,0 +1,58 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace svoboda\time;
|
||||||
|
|
||||||
|
// Built-in libraries
|
||||||
|
use DateTime as datetime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Statement
|
||||||
|
*
|
||||||
|
*By ATOM format: "Y-m-d\\TH:i:sP"
|
||||||
|
*
|
||||||
|
* @see https://www.youtube.com/watch?v=DGqDSEEZjwA Statement of Svoboda creation
|
||||||
|
* @see https://web.archive.org/web/20250202093707/https://www.youtube.com/watch?v=DGqDSEEZjwA Statement of Svoboda creation (WebArchive)
|
||||||
|
*
|
||||||
|
* @package svoboda\time
|
||||||
|
*
|
||||||
|
* @method
|
||||||
|
*
|
||||||
|
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||||
|
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||||
|
*/
|
||||||
|
final class statement
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Statement
|
||||||
|
*
|
||||||
|
* @see https://en.wikipedia.org/wiki/Atom_(web_standard) ATOM
|
||||||
|
* @see https://www.php.net/manual/en/class.datetimeinterface.php#datetimeinterface.constants.atom DateTime ATOM
|
||||||
|
*
|
||||||
|
* @var string $statement Time of the statement of Svoboda creation was publishedsda
|
||||||
|
*/
|
||||||
|
protected static string $statement = '2024-06-01T20:15:25+00:00';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Datetime
|
||||||
|
*
|
||||||
|
* @return datetime DateTime implementator for the statement publishment time
|
||||||
|
*/
|
||||||
|
public static function datetime(): datetime
|
||||||
|
{
|
||||||
|
// Exit (success)
|
||||||
|
return datetime::createFromFormat(datetime::ATOM, static::$statement);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Timestamp
|
||||||
|
*
|
||||||
|
* @return int Seconds that passed from the statement was publishment
|
||||||
|
*/
|
||||||
|
public static function timestamp(): int
|
||||||
|
{
|
||||||
|
// Exit (success)
|
||||||
|
return new datetime()->getTimestamp() - static::datetime()->getTimestamp();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use svoboda\time\statement as svoboda;
|
||||||
|
|
||||||
|
// Initializing path to the composer loader file (main project)
|
||||||
|
$autoload =
|
||||||
|
__DIR__ . DIRECTORY_SEPARATOR .
|
||||||
|
'..' . DIRECTORY_SEPARATOR .
|
||||||
|
'..' . DIRECTORY_SEPARATOR .
|
||||||
|
'..' . DIRECTORY_SEPARATOR .
|
||||||
|
'vendor' . DIRECTORY_SEPARATOR .
|
||||||
|
'autoload.php';
|
||||||
|
|
||||||
|
// Reinitializing path to the composer loaded file (depencendy project)
|
||||||
|
if (!file_exists($autoload))
|
||||||
|
$autoload = __DIR__ . DIRECTORY_SEPARATOR .
|
||||||
|
'..' . DIRECTORY_SEPARATOR .
|
||||||
|
'..' . DIRECTORY_SEPARATOR .
|
||||||
|
'..' . DIRECTORY_SEPARATOR .
|
||||||
|
'..' . DIRECTORY_SEPARATOR .
|
||||||
|
'..' . DIRECTORY_SEPARATOR .
|
||||||
|
'autoload.php';
|
||||||
|
|
||||||
|
// Importing files of thr project and dependencies
|
||||||
|
require($autoload);
|
||||||
|
|
||||||
|
echo "Started testing\n\n\n";
|
||||||
|
|
||||||
|
// Initializing the counter of actions
|
||||||
|
$action = 0;
|
||||||
|
|
||||||
|
var_dump(svoboda::timestamp());
|
Loading…
Reference in New Issue