Skip to content

Commit

Permalink
Create Project
Browse files Browse the repository at this point in the history
  • Loading branch information
hungnguyenhp committed Sep 22, 2021
0 parents commit ebaf0e8
Show file tree
Hide file tree
Showing 10 changed files with 331 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# GitHub Action for PHP Date and Time Helper & Libraries by HungNG
name: Testing PHP Date and Time Helper & Libraries by HungNG
on: [ push, pull_request ]
jobs:
build:
strategy:
matrix:
operating-system: [ ubuntu-latest, windows-latest, macos-latest ]
php-versions: [ '5.6', '7.0', '8.0' ]
runs-on: ${{ matrix.operating-system }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 # From https://github.com/shivammathur/setup-php
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, intl, curl, json, openssl, iconv, sodium, mcrypt, bcmath
coverage: xdebug #optional
- name: Get composer cache directory
id: composercache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composercache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader
- name: Test Date and Time Helper
run: php ./test/test.php
127 changes: 127 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# Created by .ignore support plugin (hsz.mobi)
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/dictionaries
.idea/**/shelf

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# CMake
cmake-build-debug/
cmake-build-release/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests
### macOS template
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### Example user template template
### Example user template

# IntelliJ project files
.idea
*.iml
out
gen### SublimeText template
# Cache files for Sublime Text
*.tmlanguage.cache
*.tmPreferences.cache
*.stTheme.cache

# Workspace files are user-specific
*.sublime-workspace

# Project files should be checked into the repository, unless a significant
# proportion of contributors will probably not be using Sublime Text
# *.sublime-project

# SFTP configuration file
sftp-config.json

# Package control specific files
Package Control.last-run
Package Control.ca-list
Package Control.ca-bundle
Package Control.system-ca-bundle
Package Control.cache/
Package Control.ca-certs/
Package Control.merged-ca-bundle
Package Control.user-ca-bundle
oscrypto-ca-bundle.crt
bh_unicode_properties.cache

# Sublime-github package stores a github token in this file
# https://packagecontrol.io/packages/sublime-github
GitHub.sublime-settings

## Composer
/vendor/
/tests/*
composer.lock

cache/*
!cache/.htaccess
!cache/.gitkeep
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# CHANGELOG

## [1.0.0] - 2021/09/22

### Added

- [x] Init Project

## Contact & Support

If any question & request, please contact following information

| Name | Email | Skype | Facebook |
| ----------- | -------------------- | ---------------- | ------------- |
| Hung Nguyen | dev@nguyenanhung.com | nguyenanhung5891 | @nguyenanhung |
9 changes: 9 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
The MIT License (MIT)

Copyright © 2021 Nguyen An Hung <dev@nguyenanhung.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[![Latest Stable Version](http://poser.pugx.org/nguyenanhung/date-helper/v)](https://packagist.org/packages/nguyenanhung/date-helper) [![Total Downloads](http://poser.pugx.org/nguyenanhung/date-helper/downloads)](https://packagist.org/packages/nguyenanhung/date-helper) [![Latest Unstable Version](http://poser.pugx.org/nguyenanhung/date-helper/v/unstable)](https://packagist.org/packages/nguyenanhung/date-helper) [![License](http://poser.pugx.org/nguyenanhung/date-helper/license)](https://packagist.org/packages/nguyenanhung/date-helper) [![PHP Version Require](http://poser.pugx.org/nguyenanhung/date-helper/require/php)](https://packagist.org/packages/nguyenanhung/date-helper)

# Date & Time Helper

Date & Time Helper, basic, simple and light

## Contact & Support

If any question & request, please contact following information

| Name | Email | Skype | Facebook |
| ----------- | -------------------- | ---------------- | ------------- |
| Hung Nguyen | dev@nguyenanhung.com | nguyenanhung5891 | @nguyenanhung |

From Vietnam with Love <3
33 changes: 33 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"type": "library",
"name": "nguyenanhung/date-helper",
"description": "Date & Time Helper, basic, simple and light",
"keywords": [
"helper",
"date",
"php"
],
"homepage": "https://github.com/nguyenanhung/date-helper",
"license": "MIT",
"minimum-stability": "stable",
"authors": [
{
"name": "Nguyen An Hung",
"email": "dev@nguyenanhung.com",
"homepage": "https://nguyenanhung.com",
"role": "Developer"
}
],
"require": {
"php": ">=5.6",
"ext-mbstring": "*"
},
"autoload": {
"psr-4": {
"nguyenanhung\\Libraries\\DateAndTime\\": "src/"
},
"files": [
"helpers/helpers.php"
]
}
}
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Document
9 changes: 9 additions & 0 deletions helpers/helpers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
/**
* Project date-helper
* Created by PhpStorm
* User: 713uk13m <dev@nguyenanhung.com>
* Copyright: 713uk13m <dev@nguyenanhung.com>
* Date: 09/22/2021
* Time: 19:11
*/
79 changes: 79 additions & 0 deletions src/DateAndTime.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php
/**
* Project date-helper
* Created by PhpStorm
* User: 713uk13m <dev@nguyenanhung.com>
* Copyright: 713uk13m <dev@nguyenanhung.com>
* Date: 09/22/2021
* Time: 19:12
*/

namespace nguyenanhung\Libraries\DateAndTime;

use DateTime;
use DateTimeZone;
use Exception;

if (!class_exists('nguyenanhung\Libraries\DateAndTime\DateAndTime')) {
class DateAndTime
{
/**
* Function zuluTime
*
* @return string|null
* @author : 713uk13m <dev@nguyenanhung.com>
* @copyright: 713uk13m <dev@nguyenanhung.com>
* @time : 08/18/2021 25:38
*/
public static function zuluTime()
{
try {
$dateUTC = new DateTime("now", new DateTimeZone("UTC"));

return $dateUTC->format('Y-m-d\TH:i:s\Z');
} catch (Exception $e) {
return null;
}
}

/**
* Function expireTime
*
* @param int $duration
*
* @return string
* @author: 713uk13m <dev@nguyenanhung.com>
* @time : 2019-07-15 10:57
*
*/
public static function expireTime($duration = 1)
{
try {
$expire = $duration <= 1 ? new DateTime("+0 days") : new DateTime("+$duration days");
$expireTime = $expire->format('Y-m-d') . ' 23:59:59';
} catch (Exception $e) {
$expireTime = date('Y-m-d') . ' 23:59:59';
}

return $expireTime;
}

/**
* Function generateOTPExpireTime
*
* @param int $hour
*
* @return string
* @throws \Exception
* @author: 713uk13m <dev@nguyenanhung.com>
* @time : 2018-12-06 16:03
*
*/
public static function generateOTPExpireTime($hour = 4)
{
$time = new DateTime('+' . $hour . ' days');

return $time->format('Y-m-d H:i:s');
}
}
}
9 changes: 9 additions & 0 deletions test/test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
/**
* Project date-helper
* Created by PhpStorm
* User: 713uk13m <dev@nguyenanhung.com>
* Copyright: 713uk13m <dev@nguyenanhung.com>
* Date: 09/22/2021
* Time: 19:11
*/

0 comments on commit ebaf0e8

Please sign in to comment.