Commit 8841d8da authored by Brad King's avatar Brad King
Browse files

chrono: update to 0.4

The chrono 0.3.1 release was yanked from crates.io due to breaking
semantic versioning (chrono issue 156).  Now chrono 0.4 has been
released to support serde 1.0.
parent b2bcc6ae
......@@ -20,7 +20,7 @@ reqwest = "~0.6"
serde_derive = "^1.0"
url = "^1.4"
chrono = { version = "~0.3.1", features = ["serde"] }
chrono = { version = "~0.4", features = ["serde"] }
error-chain = ">= 0.9, < 0.11"
serde = "~1.0"
serde_json = "^1.0"
......
......@@ -14,7 +14,7 @@
//! Gitlab does not have consistent structures for its hooks, so they often change from
//! version to version.
use crates::chrono::{DateTime, UTC};
use crates::chrono::{DateTime, Utc};
use crates::serde::{Deserialize, Deserializer, Serialize, Serializer};
use crates::serde::de::{Error, Unexpected};
use crates::serde_json::{self, Value};
......@@ -64,9 +64,9 @@ pub struct ProjectSystemHook {
/// The event which occurred.
pub event_name: ProjectEvent,
/// When the project was created.
pub created_at: DateTime<UTC>,
pub created_at: DateTime<Utc>,
/// When the project was last updated.
pub updated_at: DateTime<UTC>,
pub updated_at: DateTime<Utc>,
/// The display name of the project.
pub name: String,
......@@ -140,9 +140,9 @@ pub struct ProjectMemberSystemHook {
/// The event which occurred.
pub event_name: ProjectMemberEvent,
/// When the membership was created.
pub created_at: DateTime<UTC>,
pub created_at: DateTime<Utc>,
/// When the membership was last updated.
pub updated_at: DateTime<UTC>,
pub updated_at: DateTime<Utc>,
/// The name of the project.
pub project_name: String,
/// The path of the project (used for URLs).
......@@ -185,9 +185,9 @@ pub struct UserSystemHook {
/// The event which occurred.
pub event_name: UserEvent,
/// When the user account was created.
pub created_at: DateTime<UTC>,
pub created_at: DateTime<Utc>,
/// When the user account was last updated.
pub updated_at: DateTime<UTC>,
pub updated_at: DateTime<Utc>,
/// The name of the user.
pub name: String,
/// The email address of the user.
......@@ -218,9 +218,9 @@ pub struct KeySystemHook {
/// The event which occurred.
pub event_name: KeyEvent,
/// When the key was added.
pub created_at: DateTime<UTC>,
pub created_at: DateTime<Utc>,
/// When the key was last updated.
pub updated_at: DateTime<UTC>,
pub updated_at: DateTime<Utc>,
/// The username of the user.
pub username: String,
/// The content of the key.
......@@ -249,9 +249,9 @@ pub struct GroupSystemHook {
/// The event which occurred.
pub event_name: GroupEvent,
/// When the group was created.
pub created_at: DateTime<UTC>,
pub created_at: DateTime<Utc>,
/// When the group was last updated.
pub updated_at: DateTime<UTC>,
pub updated_at: DateTime<Utc>,
/// The name of the group.
pub name: String,
/// The path of the group (used for URLs).
......@@ -284,9 +284,9 @@ pub struct GroupMemberSystemHook {
/// The event which occurred.
pub event_name: GroupMemberEvent,
/// When the group membership was added.
pub created_at: DateTime<UTC>,
pub created_at: DateTime<Utc>,
/// When the group membership was last updated.
pub updated_at: DateTime<UTC>,
pub updated_at: DateTime<Utc>,
/// The name of the group.
pub group_name: String,
/// The path of the group (used for URLs).
......@@ -327,9 +327,9 @@ pub struct PushSystemHook {
/// XXX(gitlab): Bug in Gitlab; it should not send this.
object_kind: String,
/// When the push occurred.
pub created_at: DateTime<UTC>,
pub created_at: DateTime<Utc>,
/// When the push
pub updated_at: DateTime<UTC>,
pub updated_at: DateTime<Utc>,
/// The old object ID of the ref that was pushed.
pub before: ObjectId,
/// The new object ID of the ref that was pushed.
......
......@@ -6,7 +6,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use crates::chrono::{NaiveDate, TimeZone, UTC};
use crates::chrono::{NaiveDate, TimeZone, Utc};
use crates::serde::de::DeserializeOwned;
use crates::serde_json::from_reader;
......@@ -36,10 +36,10 @@ fn test_read_award_emoji() {
"https://secure.gravatar.com/avatar/2f5f7e99190174edb5a2f66b8653b0b2?s=80&d=identicon");
assert_eq!(award_emoji.user.id, UserId::new(13));
assert_eq!(award_emoji.created_at,
UTC.ymd(2016, 12, 7)
Utc.ymd(2016, 12, 7)
.and_hms_milli(16, 23, 46, 742));
assert_eq!(award_emoji.updated_at,
UTC.ymd(2016, 12, 7)
Utc.ymd(2016, 12, 7)
.and_hms_milli(16, 23, 46, 742));
assert_eq!(award_emoji.awardable_id(),
AwardableId::Note(NoteId::new(177359)));
......@@ -63,7 +63,7 @@ fn test_read_commit_note() {
"https://secure.gravatar.com/avatar/2f5f7e99190174edb5a2f66b8653b0b2?s=80&d=identicon");
assert_eq!(commit_note.author.id, UserId::new(13));
assert_eq!(commit_note.created_at,
UTC.ymd(2016, 12, 7)
Utc.ymd(2016, 12, 7)
.and_hms_milli(16, 28, 33, 966));
}
......@@ -82,11 +82,11 @@ fn test_read_commit_status() {
.to_string()));
assert_eq!(commit_status.description, Some("expected".to_string()));
assert_eq!(commit_status.created_at,
UTC.ymd(2016, 11, 8)
Utc.ymd(2016, 11, 8)
.and_hms_milli(14, 35, 32, 627));
assert_eq!(commit_status.started_at, None);
assert_eq!(commit_status.finished_at,
Some(UTC.ymd(2016, 11, 8)
Some(Utc.ymd(2016, 11, 8)
.and_hms_milli(14, 35, 32, 629)));
assert_eq!(commit_status.allow_failure, false);
assert_eq!(commit_status.author.username, "buildbot");
......@@ -111,10 +111,10 @@ fn test_read_issue() {
assert_eq!(issue.description, Some("".to_string()));
assert_eq!(issue.state, IssueState::Closed);
assert_eq!(issue.created_at,
UTC.ymd(2016, 10, 30)
Utc.ymd(2016, 10, 30)
.and_hms_milli(18, 54, 28, 954));
assert_eq!(issue.updated_at,
UTC.ymd(2017, 1, 13)
Utc.ymd(2017, 1, 13)
.and_hms_milli(21, 45, 20, 901));
assert!(issue.labels.is_empty());
assert!(issue.milestone.is_none());
......@@ -161,10 +161,10 @@ fn test_read_issue_reference() {
a webhook for new projects. An API needs added for this.\n\nCc: @brad.king".to_string()));
assert_eq!(issue.state, IssueState::Closed);
assert_eq!(issue.created_at,
UTC.ymd(2016, 10, 4)
Utc.ymd(2016, 10, 4)
.and_hms_milli(18, 59, 37, 178));
assert_eq!(issue.updated_at,
UTC.ymd(2016, 10, 4)
Utc.ymd(2016, 10, 4)
.and_hms_milli(20, 18, 57, 519));
assert!(issue.labels.is_empty());
assert!(issue.milestone.is_none());
......@@ -226,10 +226,10 @@ fn test_read_merge_request() {
assert_eq!(merge_request.description, Some("Fixes #5.".to_string()));
assert_eq!(merge_request.state, MergeRequestState::Merged);
assert_eq!(merge_request.created_at,
UTC.ymd(2016, 10, 4)
Utc.ymd(2016, 10, 4)
.and_hms_milli(19, 56, 43, 276));
assert_eq!(merge_request.updated_at,
UTC.ymd(2016, 10, 4)
Utc.ymd(2016, 10, 4)
.and_hms_milli(20, 18, 57, 940));
assert_eq!(merge_request.target_branch, "master");
assert_eq!(merge_request.source_branch, "add_hook-api");
......@@ -288,10 +288,10 @@ fn test_read_note() {
"https://secure.gravatar.com/avatar/0617392a2f9fd505720d0c42cefc1a10?s=80&d=identicon");
assert_eq!(note.author.id, UserId::new(10));
assert_eq!(note.created_at,
UTC.ymd(2016, 10, 4)
Utc.ymd(2016, 10, 4)
.and_hms_milli(20, 18, 57, 786));
assert_eq!(note.updated_at,
UTC.ymd(2016, 10, 4)
Utc.ymd(2016, 10, 4)
.and_hms_milli(20, 18, 57, 786));
assert_eq!(note.system, true);
assert_eq!(note.noteable_id(),
......@@ -324,10 +324,10 @@ fn test_read_project() {
assert_eq!(project.path_with_namespace, "utils/rust-gitlab");
assert_eq!(project.container_registry_enabled, Some(true));
assert_eq!(project.created_at,
UTC.ymd(2016, 6, 29)
Utc.ymd(2016, 6, 29)
.and_hms_milli(17, 35, 12, 495));
assert_eq!(project.last_activity_at,
UTC.ymd(2017, 5, 24)
Utc.ymd(2017, 5, 24)
.and_hms_milli(19, 40, 9, 941));
assert_eq!(project.shared_runners_enabled, true);
assert_eq!(project.lfs_enabled, true);
......@@ -374,7 +374,7 @@ fn test_read_project_hook() {
assert_eq!(project_hook.id, HookId::new(1262));
assert_eq!(project_hook.url, "http://kwrobot02:8082/gitlab.kitware.com");
assert_eq!(project_hook.created_at,
UTC.ymd(2016, 12, 16)
Utc.ymd(2016, 12, 16)
.and_hms_milli(16, 37, 24, 589));
assert_eq!(project_hook.push_events, true);
assert_eq!(project_hook.tag_push_events, true);
......@@ -396,13 +396,13 @@ fn test_read_repo_branch() {
assert_eq!(commit.author_email, "ben.boeckel@kitware.com");
assert_eq!(commit.author_name, "Ben Boeckel");
assert_eq!(commit.authored_date,
UTC.ymd(2017, 5, 24)
Utc.ymd(2017, 5, 24)
.and_hms_milli(19, 40, 9, 0));
assert_eq!(commit.committed_date,
UTC.ymd(2017, 5, 24)
Utc.ymd(2017, 5, 24)
.and_hms_milli(19, 40, 14, 0));
assert_eq!(commit.created_at,
UTC.ymd(2017, 5, 24)
Utc.ymd(2017, 5, 24)
.and_hms_milli(19, 40, 14, 0));
assert_eq!(commit.committer_email, "kwrobot@kitware.com");
assert_eq!(commit.committer_name, "Kitware Robot");
......@@ -439,7 +439,7 @@ fn test_read_repo_commit_detail() {
assert_eq!(repo_commit_detail.committer_name, "Kitware Robot");
assert_eq!(repo_commit_detail.committer_email, "kwrobot@kitware.com");
assert_eq!(repo_commit_detail.created_at,
UTC.ymd(2016, 11, 8)
Utc.ymd(2016, 11, 8)
.and_hms_milli(14, 30, 13, 0));
assert_eq!(repo_commit_detail.message,
"Merge topic 'mr-awards'\n\na222c553 gitlab: add a method for MR award \
......@@ -451,10 +451,10 @@ fn test_read_repo_commit_detail() {
ObjectId::new("a222c5539569cda6999b8069f1e51a5202c30711"),
]);
assert_eq!(repo_commit_detail.committed_date,
UTC.ymd(2016, 11, 8)
Utc.ymd(2016, 11, 8)
.and_hms_milli(14, 30, 13, 0));
assert_eq!(repo_commit_detail.authored_date,
UTC.ymd(2016, 11, 8)
Utc.ymd(2016, 11, 8)
.and_hms_milli(14, 30, 13, 0));
assert_eq!(repo_commit_detail.stats.additions, 8);
assert_eq!(repo_commit_detail.stats.deletions, 0);
......@@ -473,7 +473,7 @@ fn test_read_user() {
"https://secure.gravatar.com/avatar/9ddcd45fcb89d966aab95b1f1002f84c?s=80&d=identicon");
assert_eq!(user.web_url, "https://gitlab.kitware.com/kwrobot");
assert_eq!(user.created_at,
UTC.ymd(2015, 2, 26)
Utc.ymd(2015, 2, 26)
.and_hms_milli(15, 58, 34, 670));
assert_eq!(user.bio, Some("".to_string()));
assert_eq!(user.location, None);
......@@ -497,7 +497,7 @@ fn test_read_user_public() {
assert_eq!(user_public.web_url,
"https://gitlab.kitware.com/kwrobot");
assert_eq!(user_public.created_at,
UTC.ymd(2015, 2, 26)
Utc.ymd(2015, 2, 26)
.and_hms_milli(15, 58, 34, 670));
assert_eq!(user_public.bio, Some("".to_string()));
assert_eq!(user_public.location, None);
......@@ -507,18 +507,18 @@ fn test_read_user_public() {
assert_eq!(user_public.website_url, "");
assert_eq!(user_public.organization, None);
assert_eq!(user_public.last_sign_in_at,
Some(UTC.ymd(2017, 4, 27)
Some(Utc.ymd(2017, 4, 27)
.and_hms_milli(14, 59, 16, 823)));
assert_eq!(user_public.last_activity_on,
Some(NaiveDate::from_ymd(2017, 6, 6)));
assert_eq!(user_public.confirmed_at,
UTC.ymd(2015, 2, 26)
Utc.ymd(2015, 2, 26)
.and_hms_milli(15, 58, 34, 660));
assert_eq!(user_public.email, "kwrobot@kitware.com");
assert_eq!(user_public.color_scheme_id, ColorSchemeId::new(4));
assert_eq!(user_public.projects_limit, 50);
assert_eq!(user_public.current_sign_in_at,
Some(UTC.ymd(2017, 6, 5)
Some(Utc.ymd(2017, 6, 5)
.and_hms_milli(18, 46, 29, 512)));
assert!(user_public.identities.is_empty());
assert_eq!(user_public.can_create_group, true);
......
......@@ -14,7 +14,7 @@
//! problems when the types and names change inside of those. If found, issues should be filed
//! upstream.
use crates::chrono::{DateTime, NaiveDate, UTC};
use crates::chrono::{DateTime, NaiveDate, Utc};
use crates::serde::{Deserialize, Deserializer, Serialize, Serializer};
use crates::serde::de::{DeserializeOwned, Error, Unexpected};
use crates::serde_json::{self, Value};
......@@ -94,7 +94,7 @@ pub struct User {
/// The URL of the user's profile page.
pub web_url: String,
/// When the account was created.
pub created_at: DateTime<UTC>,
pub created_at: DateTime<Utc>,
/// Self-described biography of the user.
pub bio: Option<String>,
/// Geographic location of the user.
......@@ -164,7 +164,7 @@ pub struct UserPublic {
/// The URL of the user's profile page.
pub web_url: String,
/// When the account was created.
pub created_at: DateTime<UTC>,
pub created_at: DateTime<Utc>,
/// Self-described biography of the user.
pub bio: Option<String>,
/// Geographic location of the user.
......@@ -182,11 +182,11 @@ pub struct UserPublic {
pub organization: Option<String>,
/// When the user last logged in.
pub last_sign_in_at: Option<DateTime<UTC>>,
pub last_sign_in_at: Option<DateTime<Utc>>,
/// When the user last made an action.
pub last_activity_on: Option<NaiveDate>,
/// When the user's account was confirmed.
pub confirmed_at: DateTime<UTC>,
pub confirmed_at: DateTime<Utc>,
/// The primary email address for the user.
pub email: String,
......@@ -195,7 +195,7 @@ pub struct UserPublic {
/// The number of projects the user may create.
pub projects_limit: u64,
/// When the user's current session started.
pub current_sign_in_at: Option<DateTime<UTC>>,
pub current_sign_in_at: Option<DateTime<Utc>>,
/// List of identities associated with the user.
pub identities: Vec<Identity>,
......@@ -275,7 +275,7 @@ pub struct Hook {
/// The URL to contact.
pub url: String,
/// When the hook was created.
pub created_at: DateTime<UTC>,
pub created_at: DateTime<Utc>,
/// Whether the hook is contacted for push events.
pub push_events: bool,
/// Whether the hook is contacted for tag push events.
......@@ -293,7 +293,7 @@ pub struct ProjectHook {
/// The URL to contact.
pub url: String,
/// When the hook was created.
pub created_at: DateTime<UTC>,
pub created_at: DateTime<Utc>,
/// The project associated with the hook.
pub project_id: ProjectId,
/// Whether the hook is contacted for push events.
......@@ -516,9 +516,9 @@ pub struct Project {
/// supported appear to return `null`.
pub container_registry_enabled: Option<bool>,
/// When the repository was created.
pub created_at: DateTime<UTC>,
pub created_at: DateTime<Utc>,
/// When the last activity on the project occurred.
pub last_activity_at: DateTime<UTC>,
pub last_activity_at: DateTime<Utc>,
/// Whether continuous integration shared runners are enabled.
pub shared_runners_enabled: bool,
/// Whether LFS object storage is enabled.
......@@ -656,7 +656,7 @@ pub struct Member {
/// The access level of the user.
pub access_level: u64,
/// When the membership expires.
pub expires_at: Option<DateTime<UTC>>,
pub expires_at: Option<DateTime<Utc>>,
}
impl From<Member> for UserBasic {
......@@ -689,7 +689,7 @@ pub struct AccessRequester {
/// The URL of the user's profile page.
pub web_url: String,
/// When the membership request was created.
pub requested_at: DateTime<UTC>,
pub requested_at: DateTime<Utc>,
}
impl From<AccessRequester> for UserBasic {
......@@ -889,14 +889,14 @@ pub struct RepoCommit {
/// The commit author's email address.
pub author_email: String,
/// The commit's authorship date.
pub authored_date: DateTime<UTC>,
pub authored_date: DateTime<Utc>,
/// The committer's name.
pub committer_name: String,
/// The committer's email address.
pub committer_email: String,
/// The commit's commit date.
pub committed_date: DateTime<UTC>,
pub created_at: DateTime<UTC>,
pub committed_date: DateTime<Utc>,
pub created_at: DateTime<Utc>,
/// The full commit message.
pub message: String,
}
......@@ -930,14 +930,14 @@ pub struct RepoCommitDetail {
/// The commit author's email address.
pub author_email: String,
/// The commit's authorship date.
pub authored_date: DateTime<UTC>,
pub authored_date: DateTime<Utc>,
/// The committer's name.
pub committer_name: String,
/// The committer's email address.
pub committer_email: String,
/// The commit's commit date.
pub committed_date: DateTime<UTC>,
pub created_at: DateTime<UTC>,
pub committed_date: DateTime<Utc>,
pub created_at: DateTime<Utc>,
/// The full commit message.
pub message: String,
/// Statistics about the commit.
......@@ -966,11 +966,11 @@ pub struct ProjectSnippet {
/// The author of the snippet.
pub author: UserBasic,
/// When the snippet was last updated.
pub updated_at: DateTime<UTC>,
pub updated_at: DateTime<Utc>,
/// When the snippet was created.
pub created_at: DateTime<UTC>,
pub created_at: DateTime<Utc>,
/// When the snippet was created.
pub expires_at: Option<DateTime<UTC>>,
pub expires_at: Option<DateTime<Utc>>,
/// The URL of the snippet.
pub web_url: String,
}
......@@ -985,8 +985,8 @@ pub struct ProjectSnippet {
// pub title: String,
// pub description: String,
// pub state: ProjectEntityState,
// pub created_at: DateTime<UTC>,
// pub updated_at: DateTime<UTC>,
// pub created_at: DateTime<Utc>,
// pub updated_at: DateTime<Utc>,
//}
#[cfg_attr(feature="strict", serde(deny_unknown_fields))]
......@@ -1046,9 +1046,9 @@ pub struct Milestone {
/// The state of the milestone.
pub state: MilestoneState,
/// When the milestone was created.
pub created_at: DateTime<UTC>,
pub created_at: DateTime<Utc>,
/// When the milestone was last updated.
pub updated_at: DateTime<UTC>,
pub updated_at: DateTime<Utc>,
/// When the milestone is due.
pub due_date: Option<NaiveDate>,
/// When the milestone was started.
......@@ -1094,9 +1094,9 @@ pub struct Issue {
/// The state of the issue.
pub state: IssueState,
/// When the issue was created.
pub created_at: DateTime<UTC>,
pub created_at: DateTime<Utc>,
/// When the issue was last updated.
pub updated_at: DateTime<UTC>,
pub updated_at: DateTime<Utc>,
/// The labels attached to the issue.
pub labels: Vec<String>,
/// The milestone of the issue.
......@@ -1242,9 +1242,9 @@ pub struct MergeRequest {
/// The state of the merge request.
pub state: MergeRequestState,
/// When the merge request was created.
pub created_at: DateTime<UTC>,
pub created_at: DateTime<Utc>,
/// When the merge request was last updated.
pub updated_at: DateTime<UTC>,
pub updated_at: DateTime<Utc>,
/// The target branch of the merge request.
pub target_branch: String,
/// The source branch of the merge request.
......@@ -1306,9 +1306,9 @@ pub struct MergeRequestChanges {
/// The state of the merge request.
pub state: MergeRequestState,
/// When the merge request was created.
pub created_at: DateTime<UTC>,
pub created_at: DateTime<Utc>,
/// When the merge request was last updated.
pub updated_at: DateTime<UTC>,
pub updated_at: DateTime<Utc>,
/// The target branch of the merge request.
pub target_branch: String,
/// The source branch of the merge request.
......@@ -1406,7 +1406,7 @@ pub struct SshKey {
/// The public half of the SSH key.
pub key: String,
/// When the key was created.
pub created_at: DateTime<UTC>,
pub created_at: DateTime<Utc>,
/// Whether the key may push to repositories or not.
pub can_push: bool,
}
......@@ -1422,7 +1422,7 @@ pub struct SshKeyWithUser {
/// The public half of the SSH key.
pub key: String,
/// When the key was created.
pub created_at: DateTime<UTC>,
pub created_at: DateTime<Utc>,
/// The user associated with the SSH key.
pub user: UserPublic,
}
......@@ -1478,9 +1478,9 @@ pub struct Note {
/// The author of the note.
pub author: UserBasic,
/// When the note was created.
pub created_at: DateTime<UTC>,
pub created_at: DateTime<Utc>,
/// When the note was last updated.
pub updated_at: DateTime<UTC>,
pub updated_at: DateTime<Utc>,
/// Whether the note was created by a user or in response to an external action.
///
/// System notes include indications that the commit, issue, etc. was referenced elsewhere, a
......@@ -1575,9 +1575,9 @@ pub struct AwardEmoji {
/// The user which created the award.
pub user: UserBasic,
/// When the award was created.
pub created_at: DateTime<UTC>,
pub created_at: DateTime<Utc>,
/// When the award was last updated.
pub updated_at: DateTime<UTC>,
pub updated_at: DateTime<Utc>,
awardable_id: u64,
/// The type of entity that is awarded.
pub awardable_type: AwardableType,
......@@ -1625,7 +1625,7 @@ pub struct CommitNote {
/// The author of the note.
pub author: UserBasic,
/// When the note was created.
pub created_at: DateTime<UTC>,
pub created_at: DateTime<Utc>,
}
#[cfg_attr(feature="strict", serde(deny_unknown_fields))]
......@@ -1676,11 +1676,11 @@ pub struct CommitStatus {
/// The description of the commit status.
pub description: Option<String>,
/// When the commit status was created.
pub created_at: DateTime<UTC>,
pub created_at: DateTime<Utc>,
/// When the commit status started.
pub started_at: Option<DateTime<UTC>>,
pub started_at: Option<DateTime<Utc>>,
/// When the commit status completed.
pub finished_at: Option<DateTime<UTC>>,
pub finished_at: Option<DateTime<Utc>>,
/// Whether the commit status is allowed to fail.
pub allow_failure: bool,
pub coverage: Option<u64>,
......@@ -1743,7 +1743,7 @@ pub struct Event {
/// The title of the target.
pub target_title: String,
/// When the event was created.
pub created_at: DateTime<UTC>,
pub created_at: DateTime<Utc>,
pub note: Option<Note>,
/// The author of the event.
pub author: Option<UserBasic>,
......@@ -1885,11 +1885,11 @@ pub struct Build {
pub tag: bool,
pub coverage: Option<f32>,
/// When the build was created or marked as pending.
pub created_at: DateTime<UTC>,
pub created_at: DateTime<Utc>,
/// When the build was started.
pub started_at: Option<DateTime<UTC>>,
pub started_at: Option<DateTime<Utc>>,
/// When the build completed.
pub finished_at: Option<DateTime<UTC>>,
pub finished_at: Option<DateTime<Utc>>,
/// The user which ran the build.
pub user: Option<User>,
/// The artifact file uploaded from the build.
......
......@@ -13,7 +13,7 @@
//! Gitlab does not have consistent structures for its hooks, so they often change from
//! version to version.
use crates::chrono::{DateTime, NaiveDate, TimeZone, UTC};
use crates::chrono::{DateTime, NaiveDate, TimeZone, Utc};
use crates::serde::{Deserialize, Deserializer, Serialize, Serializer};
use crates::serde::de::{Error, Unexpected};
use crates::serde_json::{self, Value};
......@@ -26,7 +26,7 @@ use types::{BuildId, IssueId, IssueState, MergeRequestId, MergeRequestState, Mer
///
/// Gitlab does not use a standard date format for dates in web hooks. This structure supports
/// deserializing the formats that have been observed.
pub struct HookDate(DateTime<UTC>);
pub struct HookDate(DateTime<Utc>);
impl Serialize for HookDate {
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
......@@ -40,21 +40,21 @@ impl<'de> Deserialize<'de> for HookDate {
{
let val = String::deserialize(deserializer)?;
UTC.datetime_from_str(&val, "%Y-%m-%d %H:%M:%S UTC")
Utc.datetime_from_str(&val, "%Y-%m-%d %H:%M:%S UTC")
.or_else(|_| {
DateTime::parse_from_str(&val, "%Y-%m-%d %H:%M:%S %z")
.map_err(|err| {
D::Error::invalid_value(Unexpected::Other("hook date"),
&format!("{:?}", err).as_str())
})
.map(|dt| dt.with_timezone(&UTC))
.map(|dt| dt.with_timezone(&Utc))
})
.map(HookDate)
}
}
impl AsRef<DateTime<UTC>> for HookDate {
fn as_ref(&self) -> &DateTime<UTC> {
impl AsRef<DateTime<Utc>> for HookDate {
fn as_ref(&self) -> &DateTime<Utc> {
&self.0
}
}
......@@ -135,7 +135,7 @@ pub struct CommitHookAttrs {
pub id: ObjectId,
/// The commit message.
pub message: String,
pub timestamp: DateTime<UTC>