Browse Source

Fixed the parsing of ISO 8601 dates

tags/v0.2.1
Cédric Belin 2 weeks ago
parent
commit
6b2c0be2dd
12 changed files with 254 additions and 23 deletions
  1. +5
    -5
      etc/checkstyle.json
  2. +46
    -0
      lib/php/gitea/CommitMeta.php
  3. +2
    -2
      lib/php/gitea/hook/PayloadCommit.php
  4. +47
    -0
      lib/php/gitea/issue/StopWatch.php
  5. +3
    -3
      lib/php/gitea/repository/Repository.php
  6. +64
    -0
      lib/php/gitea/repository/RepositoryMeta.php
  7. +74
    -0
      lib/php/gitea/repository/Tag.php
  8. +3
    -3
      lib/php/gitea/user/User.php
  9. +2
    -2
      src/gitea/hook/PayloadCommit.hx
  10. +2
    -2
      src/gitea/issue/StopWatch.hx
  11. +3
    -3
      src/gitea/repository/Repository.hx
  12. +3
    -3
      src/gitea/user/User.hx

+ 5
- 5
etc/checkstyle.json View File

@@ -10,9 +10,9 @@
"gitea/user/User:new"
],
"LineLength": [
"gitea/organization/Organization",
"gitea/organization/Team",
"gitea/repository/Repository"
"gitea/organization/Organization:new",
"gitea/organization/Team:new",
"gitea/repository/Repository:new"
],
"MemberName": [
"gitea/misc/MarkdownOption",
@@ -21,8 +21,8 @@
"gitea/repository/ExternalTracker",
"gitea/repository/StatusState"
],
"UnnecessaryConstructor": [
"gitea/misc/ServerVersion"
"ReturnCount": [
"gitea/DateTools:parseIsoString"
]
},
"checks": [


+ 46
- 0
lib/php/gitea/CommitMeta.php View File

@@ -0,0 +1,46 @@
<?php
/**
* Generated by Haxe 4.1.4
*/

namespace gitea;

use \php\Boot;

/**
* Provides meta information of a commit.
*/
class CommitMeta {
/**
* @var string
* The commit hash.
*/
public $sha;
/**
* @var string
* The URL to the commit's history.
*/
public $url;

/**
* Creates new commit metadata.
*
* @param mixed $data
*
* @return void
*/
public function __construct ($data = null) {
$this->url = "";
$this->sha = "";
if ($data !== null) {
if (\Reflect::hasField($data, "sha")) {
$this->sha = \Reflect::field($data, "sha");
}
if (\Reflect::hasField($data, "url")) {
$this->url = \Reflect::field($data, "url");
}
}
}
}

Boot::registerClass(CommitMeta::class, 'gitea.CommitMeta');

+ 2
- 2
lib/php/gitea/hook/PayloadCommit.php View File

@@ -6,7 +6,7 @@
namespace gitea\hook;

use \php\Boot;
use \datetime\utils\DateTimeUtils;
use \gitea\DateTools;

/**
* Represents a commit.
@@ -104,7 +104,7 @@ class PayloadCommit {
$this->removed = \Reflect::field($data, "removed");
}
if (\Reflect::hasField($data, "timestamp") && is_string(\Reflect::field($data, "timestamp"))) {
$this->timestamp = \Date::fromTime((DateTimeUtils::fromString(\Reflect::field($data, "timestamp")) - 62135596800.0) * 1000);
$this->timestamp = DateTools::parseIsoString(\Reflect::field($data, "timestamp"));
}
if (\Reflect::hasField($data, "url") && is_string(\Reflect::field($data, "url"))) {
$this->url = \Reflect::field($data, "url");


+ 47
- 0
lib/php/gitea/issue/StopWatch.php View File

@@ -0,0 +1,47 @@
<?php
/**
* Generated by Haxe 4.1.4
*/

namespace gitea\issue;

use \php\Boot;
use \gitea\DateTools;

/**
* Represents a running stopwatch.
*/
class StopWatch {
/**
* @var \Date
* The creation date.
*/
public $created;
/**
* @var int
* The issue index.
*/
public $issueIndex;

/**
* Creates a new stopwatch.
*
* @param mixed $data
*
* @return void
*/
public function __construct ($data = null) {
$this->issueIndex = -1;
$this->created = null;
if ($data !== null) {
if (\Reflect::hasField($data, "created") && is_string(\Reflect::field($data, "created"))) {
$this->created = DateTools::parseIsoString(\Reflect::field($data, "created"));
}
if (\Reflect::hasField($data, "issue_index") && Boot::isOfType(\Reflect::field($data, "issue_index"), Boot::getClass('Int'))) {
$this->issueIndex = \Reflect::field($data, "issue_index");
}
}
}
}

Boot::registerClass(StopWatch::class, 'gitea.issue.StopWatch');

+ 3
- 3
lib/php/gitea/repository/Repository.php View File

@@ -6,7 +6,7 @@
namespace gitea\repository;

use \php\Boot;
use \datetime\utils\DateTimeUtils;
use \gitea\DateTools;
use \gitea\user\User;

/**
@@ -285,7 +285,7 @@ class Repository {
$this->cloneUrl = \Reflect::field($data, "clone_url");
}
if (\Reflect::hasField($data, "created_at") && is_string(\Reflect::field($data, "created_at"))) {
$this->createdAt = \Date::fromTime((DateTimeUtils::fromString(\Reflect::field($data, "created_at")) - 62135596800.0) * 1000);
$this->createdAt = DateTools::parseIsoString(\Reflect::field($data, "created_at"));
}
if (\Reflect::hasField($data, "default_branch") && is_string(\Reflect::field($data, "default_branch"))) {
$this->defaultBranch = \Reflect::field($data, "default_branch");
@@ -375,7 +375,7 @@ class Repository {
$this->isTemplate = \Reflect::field($data, "template");
}
if (\Reflect::hasField($data, "updated_at") && is_string(\Reflect::field($data, "updated_at"))) {
$this->updatedAt = \Date::fromTime((DateTimeUtils::fromString(\Reflect::field($data, "updated_at")) - 62135596800.0) * 1000);
$this->updatedAt = DateTools::parseIsoString(\Reflect::field($data, "updated_at"));
}
if (\Reflect::hasField($data, "watchers_count") && Boot::isOfType(\Reflect::field($data, "watchers_count"), Boot::getClass('Int'))) {
$this->watchersCount = \Reflect::field($data, "watchers_count");


+ 64
- 0
lib/php/gitea/repository/RepositoryMeta.php View File

@@ -0,0 +1,64 @@
<?php
/**
* Generated by Haxe 4.1.4
*/

namespace gitea\repository;

use \php\Boot;

/**
* Provides meta information of a repository.
*/
class RepositoryMeta {
/**
* @var string
* The full name.
*/
public $fullName;
/**
* @var int
* The repository identifier.
*/
public $id;
/**
* @var string
* The repository name.
*/
public $name;
/**
* @var string
* The username of the repository owner.
*/
public $owner;

/**
* Creates new repository metadata.
*
* @param mixed $data
*
* @return void
*/
public function __construct ($data = null) {
$this->owner = "";
$this->name = "";
$this->id = -1;
$this->fullName = "";
if ($data !== null) {
if (\Reflect::hasField($data, "full_name") && is_string(\Reflect::field($data, "full_name"))) {
$this->fullName = \Reflect::field($data, "full_name");
}
if (\Reflect::hasField($data, "id") && Boot::isOfType(\Reflect::field($data, "id"), Boot::getClass('Int'))) {
$this->id = \Reflect::field($data, "id");
}
if (\Reflect::hasField($data, "name") && is_string(\Reflect::field($data, "name"))) {
$this->name = \Reflect::field($data, "name");
}
if (\Reflect::hasField($data, "owner") && is_string(\Reflect::field($data, "owner"))) {
$this->owner = \Reflect::field($data, "owner");
}
}
}
}

Boot::registerClass(RepositoryMeta::class, 'gitea.repository.RepositoryMeta');

+ 74
- 0
lib/php/gitea/repository/Tag.php View File

@@ -0,0 +1,74 @@
<?php
/**
* Generated by Haxe 4.1.4
*/

namespace gitea\repository;

use \php\Boot;
use \gitea\CommitMeta;

/**
* Represents a repository tag.
*/
class Tag {
/**
* @var CommitMeta
* The commit metadata.
*/
public $commit;
/**
* @var string
* The tag identifier.
*/
public $id;
/**
* @var string
* The tag name.
*/
public $name;
/**
* @var string
* The URL of the `.tar.gz` archive.
*/
public $tarballUrl;
/**
* @var string
* The URL of the `.zip` archive.
*/
public $zipballUrl;

/**
* Creates a new tag.
*
* @param mixed $data
*
* @return void
*/
public function __construct ($data = null) {
$this->zipballUrl = "";
$this->tarballUrl = "";
$this->name = "";
$this->id = "";
$this->commit = null;
if ($data !== null) {
if (\Reflect::hasField($data, "commit") && \Reflect::isObject(\Reflect::field($data, "commit"))) {
$this->commit = new CommitMeta(\Reflect::field($data, "commit"));
}
if (\Reflect::hasField($data, "id") && is_string(\Reflect::field($data, "id"))) {
$this->id = \Reflect::field($data, "id");
}
if (\Reflect::hasField($data, "name") && is_string(\Reflect::field($data, "name"))) {
$this->name = \Reflect::field($data, "name");
}
if (\Reflect::hasField($data, "tarball_url") && is_string(\Reflect::field($data, "tarball_url"))) {
$this->tarballUrl = \Reflect::field($data, "tarball_url");
}
if (\Reflect::hasField($data, "zipball_url") && is_string(\Reflect::field($data, "zipball_url"))) {
$this->zipballUrl = \Reflect::field($data, "zipball_url");
}
}
}
}

Boot::registerClass(Tag::class, 'gitea.repository.Tag');

+ 3
- 3
lib/php/gitea/user/User.php View File

@@ -6,7 +6,7 @@
namespace gitea\user;

use \php\Boot;
use \datetime\utils\DateTimeUtils;
use \gitea\DateTools;

/**
* Represents a Gitea user.
@@ -80,7 +80,7 @@ class User {
$this->avatarUrl = \Reflect::field($data, "avatar_url");
}
if (\Reflect::hasField($data, "created") && is_string(\Reflect::field($data, "created"))) {
$this->created = \Date::fromTime((DateTimeUtils::fromString(\Reflect::field($data, "created")) - 62135596800.0) * 1000);
$this->created = DateTools::parseIsoString(\Reflect::field($data, "created"));
}
if (\Reflect::hasField($data, "email") && is_string(\Reflect::field($data, "email"))) {
$this->email = \Reflect::field($data, "email");
@@ -98,7 +98,7 @@ class User {
$this->language = \Reflect::field($data, "language");
}
if (\Reflect::hasField($data, "last_login") && is_string(\Reflect::field($data, "last_login"))) {
$this->lastLogin = \Date::fromTime((DateTimeUtils::fromString(\Reflect::field($data, "last_login")) - 62135596800.0) * 1000);
$this->lastLogin = DateTools::parseIsoString(\Reflect::field($data, "last_login"));
}
if (\Reflect::hasField($data, "login") && is_string(\Reflect::field($data, "login"))) {
$this->login = \Reflect::field($data, "login");


+ 2
- 2
src/gitea/hook/PayloadCommit.hx View File

@@ -1,6 +1,6 @@
package gitea.hook;

import datetime.DateTime;
import gitea.DateTools;
import haxe.DynamicAccess;

/** Represents a commit. **/
@@ -45,7 +45,7 @@ import haxe.DynamicAccess;
if (data.exists("message") && Std.isOfType(data["message"], String)) message = data["message"];
if (data.exists("modified") && Std.isOfType(data["modified"], Array)) modified = data["modified"];
if (data.exists("removed") && Std.isOfType(data["removed"], Array)) removed = data["removed"];
if (data.exists("timestamp") && Std.isOfType(data["timestamp"], String)) timestamp = DateTime.fromString(data["timestamp"]);
if (data.exists("timestamp") && Std.isOfType(data["timestamp"], String)) timestamp = DateTools.parseIsoString(data["timestamp"]);
if (data.exists("url") && Std.isOfType(data["url"], String)) url = data["url"];
if (data.exists("verification") && Reflect.isObject(data["verification"])) verification = new PayloadCommitVerification(data["verification"]);
}


+ 2
- 2
src/gitea/issue/StopWatch.hx View File

@@ -1,6 +1,6 @@
package gitea.issue;

import datetime.DateTime;
import gitea.DateTools;
import haxe.DynamicAccess;

/** Represents a running stopwatch. **/
@@ -14,7 +14,7 @@ import haxe.DynamicAccess;

/** Creates a new stopwatch. **/
public function new(?data: DynamicAccess<Any>) if (data != null) {
if (data.exists("created") && Std.isOfType(data["created"], String)) created = DateTime.fromString(data["created"]);
if (data.exists("created") && Std.isOfType(data["created"], String)) created = DateTools.parseIsoString(data["created"]);
if (data.exists("issue_index") && Std.isOfType(data["issue_index"], Int)) issueIndex = data["issue_index"];
}
}

+ 3
- 3
src/gitea/repository/Repository.hx View File

@@ -1,6 +1,6 @@
package gitea.repository;

import datetime.DateTime;
import gitea.DateTools;
import gitea.user.User;
import haxe.DynamicAccess;

@@ -136,7 +136,7 @@ import haxe.DynamicAccess;
if (data.exists("archived") && Std.isOfType(data["archived"], Bool)) isArchived = data["archived"];
if (data.exists("avatar_url") && Std.isOfType(data["avatar_url"], String)) avatarUrl = data["avatar_url"];
if (data.exists("clone_url") && Std.isOfType(data["clone_url"], String)) cloneUrl = data["clone_url"];
if (data.exists("created_at") && Std.isOfType(data["created_at"], String)) createdAt = DateTime.fromString(data["created_at"]);
if (data.exists("created_at") && Std.isOfType(data["created_at"], String)) createdAt = DateTools.parseIsoString(data["created_at"]);
if (data.exists("default_branch") && Std.isOfType(data["default_branch"], String)) defaultBranch = data["default_branch"];
if (data.exists("description") && Std.isOfType(data["description"], String)) description = data["description"];
if (data.exists("empty") && Std.isOfType(data["empty"], Bool)) isEmpty = data["empty"];
@@ -166,7 +166,7 @@ import haxe.DynamicAccess;
if (data.exists("ssh_url") && Std.isOfType(data["ssh_url"], String)) sshUrl = data["ssh_url"];
if (data.exists("stars_count") && Std.isOfType(data["stars_count"], Int)) starsCount = data["stars_count"];
if (data.exists("template") && Std.isOfType(data["template"], Bool)) isTemplate = data["template"];
if (data.exists("updated_at") && Std.isOfType(data["updated_at"], String)) updatedAt = DateTime.fromString(data["updated_at"]);
if (data.exists("updated_at") && Std.isOfType(data["updated_at"], String)) updatedAt = DateTools.parseIsoString(data["updated_at"]);
if (data.exists("watchers_count") && Std.isOfType(data["watchers_count"], Int)) watchersCount = data["watchers_count"];
if (data.exists("website") && Std.isOfType(data["website"], String)) website = data["website"];
}


+ 3
- 3
src/gitea/user/User.hx View File

@@ -1,6 +1,6 @@
package gitea.user;

import datetime.DateTime;
import gitea.DateTools;
import haxe.DynamicAccess;

/** Represents a Gitea user. **/
@@ -36,13 +36,13 @@ import haxe.DynamicAccess;
/** Creates a new user. **/
public function new(?data: DynamicAccess<Any>) if (data != null) {
if (data.exists("avatar_url") && Std.isOfType(data["avatar_url"], String)) avatarUrl = data["avatar_url"];
if (data.exists("created") && Std.isOfType(data["created"], String)) created = DateTime.fromString(data["created"]);
if (data.exists("created") && Std.isOfType(data["created"], String)) created = DateTools.parseIsoString(data["created"]);
if (data.exists("email") && Std.isOfType(data["email"], String)) email = data["email"];
if (data.exists("full_name") && Std.isOfType(data["full_name"], String)) fullName = data["full_name"];
if (data.exists("id") && Std.isOfType(data["id"], Int)) id = data["id"];
if (data.exists("is_admin") && Std.isOfType(data["is_admin"], Bool)) isAdmin = data["is_admin"];
if (data.exists("language") && Std.isOfType(data["language"], String)) language = data["language"];
if (data.exists("last_login") && Std.isOfType(data["last_login"], String)) lastLogin = DateTime.fromString(data["last_login"]);
if (data.exists("last_login") && Std.isOfType(data["last_login"], String)) lastLogin = DateTools.parseIsoString(data["last_login"]);
if (data.exists("login") && Std.isOfType(data["login"], String)) login = data["login"];
}
}

Loading…
Cancel
Save