mirror of
				https://github.com/openimsdk/open-im-server.git
				synced 2025-10-31 16:32:12 +08:00 
			
		
		
		
	* feat: add logic to deploy images Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add logic to deploy images Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * fix: add ubuntu Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * fix: sync quest Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add copyright information Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add more cicd design Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * fix: fix sync Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: test file Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: test file Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: build multiarch Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: build multiarch Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add start scripts Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> --------- Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
		
			
				
	
	
		
			98 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			98 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| // Copyright © 2023 OpenIM. All rights reserved.
 | |
| //
 | |
| // Licensed under the Apache License, Version 2.0 (the "License");
 | |
| // you may not use this file except in compliance with the License.
 | |
| // You may obtain a copy of the License at
 | |
| //
 | |
| //     http://www.apache.org/licenses/LICENSE-2.0
 | |
| //
 | |
| // Unless required by applicable law or agreed to in writing, software
 | |
| // distributed under the License is distributed on an "AS IS" BASIS,
 | |
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | |
| // See the License for the specific language governing permissions and
 | |
| // limitations under the License.
 | |
| 
 | |
| package utils
 | |
| 
 | |
| import (
 | |
| 	"strconv"
 | |
| 	"time"
 | |
| )
 | |
| 
 | |
| const (
 | |
| 	TimeOffset = 8 * 3600  //8 hour offset
 | |
| 	HalfOffset = 12 * 3600 //Half-day hourly offset
 | |
| )
 | |
| 
 | |
| // Get the current timestamp by Second
 | |
| func GetCurrentTimestampBySecond() int64 {
 | |
| 	return time.Now().Unix()
 | |
| }
 | |
| 
 | |
| // Convert timestamp to time.Time type
 | |
| func UnixSecondToTime(second int64) time.Time {
 | |
| 	return time.Unix(second, 0)
 | |
| }
 | |
| 
 | |
| // Convert nano timestamp to time.Time type
 | |
| func UnixNanoSecondToTime(nanoSecond int64) time.Time {
 | |
| 	return time.Unix(0, nanoSecond)
 | |
| }
 | |
| func UnixMillSecondToTime(millSecond int64) time.Time {
 | |
| 	return time.Unix(0, millSecond*1e6)
 | |
| }
 | |
| 
 | |
| // Get the current timestamp by Nano
 | |
| func GetCurrentTimestampByNano() int64 {
 | |
| 	return time.Now().UnixNano()
 | |
| }
 | |
| 
 | |
| // Get the current timestamp by Mill
 | |
| func GetCurrentTimestampByMill() int64 {
 | |
| 	return time.Now().UnixNano() / 1e6
 | |
| }
 | |
| 
 | |
| // Get the timestamp at 0 o'clock of the day
 | |
| func GetCurDayZeroTimestamp() int64 {
 | |
| 	timeStr := time.Now().Format("2006-01-02")
 | |
| 	t, _ := time.Parse("2006-01-02", timeStr)
 | |
| 	return t.Unix() - TimeOffset
 | |
| }
 | |
| 
 | |
| // Get the timestamp at 12 o'clock on the day
 | |
| func GetCurDayHalfTimestamp() int64 {
 | |
| 	return GetCurDayZeroTimestamp() + HalfOffset
 | |
| 
 | |
| }
 | |
| 
 | |
| // Get the formatted time at 0 o'clock of the day, the format is "2006-01-02_00-00-00"
 | |
| func GetCurDayZeroTimeFormat() string {
 | |
| 	return time.Unix(GetCurDayZeroTimestamp(), 0).Format("2006-01-02_15-04-05")
 | |
| }
 | |
| 
 | |
| // Get the formatted time at 12 o'clock of the day, the format is "2006-01-02_12-00-00"
 | |
| func GetCurDayHalfTimeFormat() string {
 | |
| 	return time.Unix(GetCurDayZeroTimestamp()+HalfOffset, 0).Format("2006-01-02_15-04-05")
 | |
| }
 | |
| func GetTimeStampByFormat(datetime string) string {
 | |
| 	timeLayout := "2006-01-02 15:04:05"
 | |
| 	loc, _ := time.LoadLocation("Local")
 | |
| 	tmp, _ := time.ParseInLocation(timeLayout, datetime, loc)
 | |
| 	timestamp := tmp.Unix()
 | |
| 	return strconv.FormatInt(timestamp, 10)
 | |
| }
 | |
| 
 | |
| func TimeStringFormatTimeUnix(timeFormat string, timeSrc string) int64 {
 | |
| 	tm, _ := time.Parse(timeFormat, timeSrc)
 | |
| 	return tm.Unix()
 | |
| }
 | |
| 
 | |
| func TimeStringToTime(timeString string) (time.Time, error) {
 | |
| 	t, err := time.Parse("2006-01-02", timeString)
 | |
| 	return t, err
 | |
| }
 | |
| 
 | |
| func TimeToString(t time.Time) string {
 | |
| 	return t.Format("2006-01-02")
 | |
| }
 |