diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2019-08-15 22:46:21 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-15 22:46:21 +0800 |
commit | 85202d4784758573f80f93dbbda97a444e7ece99 (patch) | |
tree | 7957506de8657463e79f121e1b79567ef1cc84a1 /modules/migrations | |
parent | 5a44be627c055d3e9eb406ec4a91579de78b6910 (diff) | |
download | gitea-85202d4784758573f80f93dbbda97a444e7ece99.tar.gz gitea-85202d4784758573f80f93dbbda97a444e7ece99.zip |
Display ui time with customize time location (#7792)
* display ui time with customize time location
* fix lint
* rename UILocation to DefaultUILocation
* move time related functions to modules/timeutil
* fix tests
* fix tests
* fix build
* fix swagger
Diffstat (limited to 'modules/migrations')
-rw-r--r-- | modules/migrations/gitea.go | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/modules/migrations/gitea.go b/modules/migrations/gitea.go index 08244e5ab2..ddfc2ca271 100644 --- a/modules/migrations/gitea.go +++ b/modules/migrations/gitea.go @@ -21,7 +21,7 @@ import ( "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/migrations/base" "code.gitea.io/gitea/modules/setting" - "code.gitea.io/gitea/modules/util" + "code.gitea.io/gitea/modules/timeutil" gouuid "github.com/satori/go.uuid" ) @@ -106,12 +106,12 @@ func (g *GiteaLocalUploader) CreateTopics(topics ...string) error { func (g *GiteaLocalUploader) CreateMilestones(milestones ...*base.Milestone) error { var mss = make([]*models.Milestone, 0, len(milestones)) for _, milestone := range milestones { - var deadline util.TimeStamp + var deadline timeutil.TimeStamp if milestone.Deadline != nil { - deadline = util.TimeStamp(milestone.Deadline.Unix()) + deadline = timeutil.TimeStamp(milestone.Deadline.Unix()) } if deadline == 0 { - deadline = util.TimeStamp(time.Date(9999, 1, 1, 0, 0, 0, 0, setting.UILocation).Unix()) + deadline = timeutil.TimeStamp(time.Date(9999, 1, 1, 0, 0, 0, 0, setting.DefaultUILocation).Unix()) } var ms = models.Milestone{ RepoID: g.repo.ID, @@ -121,7 +121,7 @@ func (g *GiteaLocalUploader) CreateMilestones(milestones ...*base.Milestone) err DeadlineUnix: deadline, } if ms.IsClosed && milestone.Closed != nil { - ms.ClosedDateUnix = util.TimeStamp(milestone.Closed.Unix()) + ms.ClosedDateUnix = timeutil.TimeStamp(milestone.Closed.Unix()) } mss = append(mss, &ms) } @@ -175,7 +175,7 @@ func (g *GiteaLocalUploader) CreateReleases(releases ...*base.Release) error { IsDraft: release.Draft, IsPrerelease: release.Prerelease, IsTag: false, - CreatedUnix: util.TimeStamp(release.Created.Unix()), + CreatedUnix: timeutil.TimeStamp(release.Created.Unix()), } // calc NumCommits @@ -194,7 +194,7 @@ func (g *GiteaLocalUploader) CreateReleases(releases ...*base.Release) error { Name: asset.Name, DownloadCount: int64(*asset.DownloadCount), Size: int64(*asset.Size), - CreatedUnix: util.TimeStamp(asset.Created.Unix()), + CreatedUnix: timeutil.TimeStamp(asset.Created.Unix()), } // download attachment @@ -265,10 +265,10 @@ func (g *GiteaLocalUploader) CreateIssues(issues ...*base.Issue) error { IsLocked: issue.IsLocked, MilestoneID: milestoneID, Labels: labels, - CreatedUnix: util.TimeStamp(issue.Created.Unix()), + CreatedUnix: timeutil.TimeStamp(issue.Created.Unix()), } if issue.Closed != nil { - is.ClosedUnix = util.TimeStamp(issue.Closed.Unix()) + is.ClosedUnix = timeutil.TimeStamp(issue.Closed.Unix()) } // TODO: add reactions iss = append(iss, &is) @@ -307,7 +307,7 @@ func (g *GiteaLocalUploader) CreateComments(comments ...*base.Comment) error { OriginalAuthor: comment.PosterName, OriginalAuthorID: comment.PosterID, Content: comment.Content, - CreatedUnix: util.TimeStamp(comment.Created.Unix()), + CreatedUnix: timeutil.TimeStamp(comment.Created.Unix()), }) // TODO: Reactions @@ -453,15 +453,15 @@ func (g *GiteaLocalUploader) newPullRequest(pr *base.PullRequest) (*models.PullR IsClosed: pr.State == "closed", IsLocked: pr.IsLocked, Labels: labels, - CreatedUnix: util.TimeStamp(pr.Created.Unix()), + CreatedUnix: timeutil.TimeStamp(pr.Created.Unix()), }, } if pullRequest.Issue.IsClosed && pr.Closed != nil { - pullRequest.Issue.ClosedUnix = util.TimeStamp(pr.Closed.Unix()) + pullRequest.Issue.ClosedUnix = timeutil.TimeStamp(pr.Closed.Unix()) } if pullRequest.HasMerged && pr.MergedTime != nil { - pullRequest.MergedUnix = util.TimeStamp(pr.MergedTime.Unix()) + pullRequest.MergedUnix = timeutil.TimeStamp(pr.MergedTime.Unix()) pullRequest.MergedCommitID = pr.MergeCommitSHA pullRequest.MergerID = g.doer.ID } |