Skip to content

Commit

Permalink
Fix Create issue and add datetime front class
Browse files Browse the repository at this point in the history
  • Loading branch information
kekefreedog committed Jan 15, 2024
1 parent 5adb04a commit b7ad2e4
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 4 deletions.
8 changes: 5 additions & 3 deletions docs/Api/SchemaApiRequest.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
runme:
id: 01HJTNJC60GAMR6TQV7XXB1C5Z
version: v2.0
version: v2.2
---

# ___Api___ __Schema of request__
Expand All @@ -26,6 +26,7 @@ let body = {
filters: [
name: "Home"
],
data: object|Array<any>
sort: "asc",
options: [
limit: 1 // Limit number of item by one,
Expand All @@ -44,8 +45,9 @@ Batching allow you to send multiple requests as a single transaction.

By default, supported request are : `create`, `delete`, `update`

Exemple :
```json
Exemple :

```json {"id":"01HM7MGZ911E1CACD7M8SVYH1Z"}
{
"requests": [
{
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/ApiV2Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static function post():void {

# Declare content
$content = self::Model()
->create($_POST ?? [])
->create(Controller::getHttpRequestData())
;

# Set response
Expand Down
74 changes: 74 additions & 0 deletions src/Front/Library/Utility/DateTime.ts
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';
;

}

}
1 change: 1 addition & 0 deletions src/Front/Types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import Crazypage from "./../Library/Crazypage";
*/
export {default as Componentregister} from "./../Library/Componentregister";
export {default as NavigatorClient} from "./../Library/Navigator/Client";
export {default as UtilityDateTime} from "./../Library/Utility/DateTime";
export {default as ColorSchema} from "./../Library/Utility/ColorSchema";
export {default as UtilityProcess} from "./../Library/Utility/Process";
export {default as UtilityObjects} from "./../Library/Utility/Objects";
Expand Down
1 change: 1 addition & 0 deletions src/Front/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/
export {default as Componentregister} from "./Library/Componentregister";
export {default as NavigatorClient} from "./Library/Navigator/Client";
export {default as UtilityDateTime} from "./Library/Utility/DateTime";
export {default as ColorSchema} from "./Library/Utility/ColorSchema";
export {default as UtilityProcess} from "./Library/Utility/Process";
export {default as UtilityObjects} from "./Library/Utility/Objects";
Expand Down

0 comments on commit b7ad2e4

Please sign in to comment.