Skip to content

Commit

Permalink
added date function
Browse files Browse the repository at this point in the history
  • Loading branch information
kneerunjun committed Dec 29, 2020
1 parent 74331d0 commit 1d9a932
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions time.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,11 @@ func ElapsedSecondsNow() int {
hr, min, sec := time.Now().Clock()
return (hr * 3600) + (min * 60) + sec
}

// DisplayDateNow : date and the time suitable for displays
// Like the blogs do it 28-Mar 1982 01:00:00
func DisplayDateNow() string {
yr, mn, dy := time.Now().Date()
hr, min, sec := time.Now().Clock()
return fmt.Sprintf("%d-%.3s %d %02d:%02d:%02d", dy, mn, yr, hr, min, sec)
}
7 changes: 7 additions & 0 deletions time_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package scheduling

import "testing"

func TestDisplayTime(t *testing.T) {
t.Log(DisplayDateNow())
}

0 comments on commit 1d9a932

Please sign in to comment.