-
Notifications
You must be signed in to change notification settings - Fork 666
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 #814 from trheyi/main
Neo API and Conversation Management Refactoring
- Loading branch information
Showing
10 changed files
with
637 additions
and
352 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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,44 @@ | ||
package assistant | ||
|
||
import ( | ||
"fmt" | ||
"strconv" | ||
"time" | ||
) | ||
|
||
func getTimestamp(v interface{}) (int64, error) { | ||
switch v := v.(type) { | ||
case int64: | ||
return v, nil | ||
case int: | ||
return int64(v), nil | ||
|
||
case string: | ||
if ts, err := time.Parse(time.RFC3339, v); err == nil { | ||
return ts.UnixNano(), nil | ||
} | ||
|
||
// MySQL format | ||
if ts, err := time.Parse("2006-01-02 15:04:05", v); err == nil { | ||
return ts.UnixNano(), nil | ||
} | ||
|
||
// UnixNano format | ||
if ts, err := strconv.ParseInt(v, 10, 64); err == nil { | ||
return ts, nil | ||
} | ||
|
||
} | ||
return 0, fmt.Errorf("invalid timestamp type") | ||
} | ||
|
||
func stringToTimestamp(v string) (int64, error) { | ||
return strconv.ParseInt(v, 10, 64) | ||
} | ||
|
||
func timeToMySQLFormat(ts int64) string { | ||
if ts == 0 { | ||
return "0000-00-00 00:00:00" | ||
} | ||
return time.Unix(ts/1e9, ts%1e9).Format("2006-01-02 15:04:05") | ||
} |
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
Oops, something went wrong.