-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from bradzhang717/20240226_allchains
20240226 update inds_getAllChains api
- Loading branch information
Showing
8 changed files
with
178 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Copyright (c) 2023-2024 The UXUY Developer Team | ||
// License: | ||
// MIT License | ||
|
||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
|
||
// The above copyright notice and this permission notice shall be included in all | ||
// copies or substantial portions of the Software. | ||
|
||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
//SOFTWARE | ||
|
||
package utils | ||
|
||
import ( | ||
"github.com/uxuycom/indexer/xylog" | ||
"strconv" | ||
"time" | ||
) | ||
|
||
var ( | ||
dateFormat = "20060102" | ||
dateLineFormat = "2006-01-02" | ||
hourFormat = "2006010215" | ||
hourLineFormat = "2006-01-02-15" | ||
timeFormat = "20060102 15:23:26" | ||
timeLineFormat = "2006-01-02 15:23:26" | ||
) | ||
|
||
func BeforeYesterdayHour() time.Time { | ||
yesterday := time.Now().Add(-24 * time.Hour) | ||
return Hour(yesterday.Add(-24 * time.Hour)) | ||
} | ||
|
||
func YesterdayHour() time.Time { | ||
return Hour(time.Now().Add(-24 * time.Hour)) | ||
} | ||
|
||
func Hour(tm time.Time) time.Time { | ||
return tm.Truncate(time.Hour) | ||
} | ||
|
||
func TimeHourInt(tm time.Time) uint64 { | ||
format := tm.Format(hourFormat) | ||
tmInt, err := strconv.ParseUint(format, 10, 32) | ||
if err != nil { | ||
xylog.Logger.Errorf("TimeHourInt err!, err = %v ", err) | ||
} | ||
return tmInt | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright (c) 2023-2024 The UXUY Developer Team | ||
// License: | ||
// MIT License | ||
|
||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
|
||
// The above copyright notice and this permission notice shall be included in all | ||
// copies or substantial portions of the Software. | ||
|
||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
//SOFTWARE | ||
|
||
package utils | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
) | ||
|
||
func Test_Hour(t *testing.T) { | ||
t.Logf("hour: %v", Hour(time.Now())) | ||
} | ||
|
||
func Test_Yesterday(t *testing.T) { | ||
t.Logf("hour: %v", YesterdayHour()) | ||
} | ||
|
||
func Test_BeforeYesterdayHour(t *testing.T) { | ||
t.Logf("hour: %v", BeforeYesterdayHour()) | ||
} | ||
|
||
func Test_TimeHour(t *testing.T) { | ||
now := Hour(time.Now()) | ||
yesterday := YesterdayHour() | ||
beforeYesterday := BeforeYesterdayHour() | ||
t.Logf("now: %v", TimeHourInt(now)) | ||
t.Logf("yesterday: %v", TimeHourInt(yesterday)) | ||
t.Logf("beforeYesterday: %v", TimeHourInt(beforeYesterday)) | ||
} |