Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
forgefriends
Forgefriends
Commits
7a3ac62f
Verified
Commit
7a3ac62f
authored
Nov 09, 2021
by
Loïc Dachary
Browse files
activitypub: go-fed conformant Clock instance
Signed-off-by:
Loïc Dachary
<
loic@dachary.org
>
parent
c023aee5
Changes
2
Hide whitespace changes
Inline
Side-by-side
modules/activitypub/clock.go
0 → 100644
View file @
7a3ac62f
// Copyright 2021 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package
activitypub
import
(
"time"
"code.gitea.io/gitea/modules/setting"
"github.com/go-fed/activity/pub"
)
var
_
pub
.
Clock
=
&
Clock
{}
// Clock struct
type
Clock
struct
{
}
// NewClock function
func
NewClock
()
(
c
*
Clock
,
err
error
)
{
c
=
&
Clock
{}
return
}
// Now function
func
(
c
*
Clock
)
Now
()
time
.
Time
{
return
time
.
Now
()
.
In
(
setting
.
DefaultUILocation
)
}
modules/activitypub/clock_test.go
0 → 100644
View file @
7a3ac62f
// Copyright 2021 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package
activitypub
import
(
"regexp"
"testing"
"time"
"code.gitea.io/gitea/modules/setting"
"github.com/stretchr/testify/assert"
)
func
TestClock
(
t
*
testing
.
T
)
{
DefaultUILocation
:=
setting
.
DefaultUILocation
defer
func
()
{
setting
.
DefaultUILocation
=
DefaultUILocation
}()
c
,
err
:=
NewClock
()
assert
.
NoError
(
t
,
err
)
setting
.
DefaultUILocation
,
err
=
time
.
LoadLocation
(
"UTC"
)
assert
.
NoError
(
t
,
err
)
assert
.
Regexp
(
t
,
regexp
.
MustCompile
(
`\+0000$`
),
c
.
Now
()
.
Format
(
time
.
Layout
))
setting
.
DefaultUILocation
,
err
=
time
.
LoadLocation
(
"Europe/Paris"
)
assert
.
NoError
(
t
,
err
)
assert
.
Regexp
(
t
,
regexp
.
MustCompile
(
`\+0[21]00$`
),
c
.
Now
()
.
Format
(
time
.
Layout
))
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment