Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
张磊
/
FileStorageBeego
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
2c868a95
authored
2013-12-21 20:44:34 +0800
by
astaxie
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
make datePatterns hide
1 parent
8ba6dbb9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
templatefunc.go
templatefunc.go
View file @
2c868a9
...
...
@@ -61,7 +61,7 @@ func DateFormat(t time.Time, layout string) (datestring string) {
}
// DateFormat pattern rules.
var
D
atePatterns
=
[]
string
{
var
d
atePatterns
=
[]
string
{
// year
"Y"
,
"2006"
,
// A full numeric representation of a year, 4 digits Examples: 1999 or 2003
"y"
,
"06"
,
//A two digit representation of a year Examples: 99 or 03
...
...
@@ -103,14 +103,14 @@ var DatePatterns = []string{
// Parse Date use PHP time format.
func
DateParse
(
dateString
,
format
string
)
(
time
.
Time
,
error
)
{
replacer
:=
strings
.
NewReplacer
(
D
atePatterns
...
)
replacer
:=
strings
.
NewReplacer
(
d
atePatterns
...
)
format
=
replacer
.
Replace
(
format
)
return
time
.
ParseInLocation
(
format
,
dateString
,
time
.
Local
)
}
// Date takes a PHP like date func to Go's time format.
func
Date
(
t
time
.
Time
,
format
string
)
string
{
replacer
:=
strings
.
NewReplacer
(
D
atePatterns
...
)
replacer
:=
strings
.
NewReplacer
(
d
atePatterns
...
)
format
=
replacer
.
Replace
(
format
)
return
t
.
Format
(
format
)
}
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
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 post a comment