-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Create issue and add datetime front class
- Loading branch information
1 parent
5adb04a
commit b7ad2e4
Showing
5 changed files
with
82 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/** | ||
* Utility | ||
* | ||
* Front TS Scrips for multiple tasks | ||
* | ||
* @package kzarshenas/crazyphp | ||
* @author kekefreedog <[email protected]> | ||
* @copyright 2022-2023 Kévin Zarshenas | ||
*/ | ||
|
||
/** | ||
* Dependances | ||
*/ | ||
|
||
/** | ||
* Date Time | ||
* | ||
* Class for manipulate time | ||
* | ||
* @package kzarshenas/crazyphp | ||
* @author kekefreedog <[email protected]> | ||
* @copyright 2022-2023 Kévin Zarshenas | ||
*/ | ||
export default class DateTime { | ||
|
||
/** Publis static methods | ||
****************************************************** | ||
*/ | ||
|
||
/** | ||
* | ||
* @param date | ||
* @returns {string} | ||
*/ | ||
public static toUTCString = (date:Date):string => { | ||
|
||
// Define pad | ||
const pad = (n:number) => n < 10 ? '0' + n : n; | ||
|
||
// Return | ||
return date.getUTCFullYear() + '-' + | ||
pad(date.getUTCMonth() + 1) + '-' + // Months are 0-indexed | ||
pad(date.getUTCDate()) + ' ' + | ||
pad(date.getUTCHours()) + ':' + | ||
pad(date.getUTCMinutes()) + ':' + | ||
pad(date.getUTCSeconds()) + ' UTC' | ||
; | ||
|
||
} | ||
|
||
/** | ||
* | ||
* @param date | ||
* @returns {string} | ||
*/ | ||
public static toISOString = (date:Date):string => { | ||
|
||
// Define pad | ||
const pad = (n:number) => n < 10 ? '0' + n : n; | ||
|
||
// Return | ||
return date.getUTCFullYear() + | ||
'-' + pad(date.getUTCMonth() + 1) + | ||
'-' + pad(date.getUTCDate()) + | ||
'T' + pad(date.getUTCHours()) + | ||
':' + pad(date.getUTCMinutes()) + | ||
':' + pad(date.getUTCSeconds()) + | ||
'.' + String((date.getUTCMilliseconds() / 1000).toFixed(3)).slice(2, 5) + | ||
'Z'; | ||
; | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters