mirror of
				https://codeberg.org/forgejo/forgejo.git
				synced 2025-10-28 04:51:07 +00:00 
			
		
		
		
	- Massive replacement of changing `code.gitea.io/gitea` to `forgejo.org`. - Resolves forgejo/discussions#258 Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7337 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org> Reviewed-by: Michael Kriese <michael.kriese@gmx.de> Reviewed-by: Beowulf <beowulf@beocode.eu> Reviewed-by: Panagiotis "Ivory" Vasilopoulos <git@n0toose.net> Co-authored-by: Gusted <postmaster@gusted.xyz> Co-committed-by: Gusted <postmaster@gusted.xyz>
		
			
				
	
	
		
			28 lines
		
	
	
	
		
			766 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			28 lines
		
	
	
	
		
			766 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| // Copyright 2017 The Gitea Authors. All rights reserved.
 | |
| // SPDX-License-Identifier: MIT
 | |
| 
 | |
| package timeutil
 | |
| 
 | |
| import (
 | |
| 	"time"
 | |
| 
 | |
| 	"forgejo.org/modules/setting"
 | |
| )
 | |
| 
 | |
| // TimeStampNano is for nano time in database, do not use it unless there is a real requirement.
 | |
| type TimeStampNano int64
 | |
| 
 | |
| // TimeStampNanoNow returns now nano int64
 | |
| func TimeStampNanoNow() TimeStampNano {
 | |
| 	return TimeStampNano(time.Now().UnixNano())
 | |
| }
 | |
| 
 | |
| // AsTime convert timestamp as time.Time in Local locale
 | |
| func (tsn TimeStampNano) AsTime() (tm time.Time) {
 | |
| 	return tsn.AsTimeInLocation(setting.DefaultUILocation)
 | |
| }
 | |
| 
 | |
| // AsTimeInLocation convert timestamp as time.Time in Local locale
 | |
| func (tsn TimeStampNano) AsTimeInLocation(loc *time.Location) time.Time {
 | |
| 	return time.Unix(0, int64(tsn)).In(loc)
 | |
| }
 |