time: Windows fix
							parent
							
								
									79b4a757c4
								
							
						
					
					
						commit
						2f8969c604
					
				|  | @ -72,16 +72,6 @@ fn remove_me_when_c_bug_is_fixed() { | |||
| pub struct C.time_t { | ||||
| } | ||||
| 
 | ||||
| struct C.tm { | ||||
| 	tm_year int | ||||
| 	tm_mon  int | ||||
| 	tm_mday int | ||||
| 	tm_hour int | ||||
| 	tm_min  int | ||||
| 	tm_sec  int | ||||
| 	tm_gmtoff int // seconds
 | ||||
| } | ||||
| 
 | ||||
| fn C.time(int) C.time_t | ||||
| 
 | ||||
| 
 | ||||
|  | @ -98,18 +88,6 @@ pub fn random() Time { | |||
| 	return time.unix(rand_unix) | ||||
| } | ||||
| 
 | ||||
| pub fn convert_ctime(t tm) Time { | ||||
| 	return Time{ | ||||
| 		year: t.tm_year + 1900 | ||||
| 		month: t.tm_mon + 1 | ||||
| 		day: t.tm_mday | ||||
| 		hour: t.tm_hour | ||||
| 		minute: t.tm_min | ||||
| 		second: t.tm_sec | ||||
| 		unix: C.mktime(&t) | ||||
| 	}.add_seconds(t.tm_gmtoff) | ||||
| } | ||||
| 
 | ||||
| // format_ss  returns a string for t in a given format YYYY-MM-DD HH:MM:SS in
 | ||||
| // 24h notation
 | ||||
| // @param
 | ||||
|  |  | |||
|  | @ -0,0 +1,29 @@ | |||
| // Copyright (c) 2019 Alexander Medvednikov. All rights reserved.
 | ||||
| // Use of this source code is governed by an MIT license
 | ||||
| // that can be found in the LICENSE file.
 | ||||
| module time | ||||
| 
 | ||||
| struct C.tm { | ||||
| 	tm_year int | ||||
| 	tm_mon  int | ||||
| 	tm_mday int | ||||
| 	tm_hour int | ||||
| 	tm_min  int | ||||
| 	tm_sec  int | ||||
| 	tm_gmtoff int // seconds
 | ||||
| } | ||||
| 
 | ||||
| pub fn convert_ctime(t tm) Time { | ||||
| 	return Time{ | ||||
| 		year: t.tm_year + 1900 | ||||
| 		month: t.tm_mon + 1 | ||||
| 		day: t.tm_mday | ||||
| 		hour: t.tm_hour | ||||
| 		minute: t.tm_min | ||||
| 		second: t.tm_sec | ||||
| 		unix: C.mktime(&t) | ||||
| 	}.add_seconds(t.tm_gmtoff) | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  | @ -0,0 +1,27 @@ | |||
| // Copyright (c) 2019 Alexander Medvednikov. All rights reserved.
 | ||||
| // Use of this source code is governed by an MIT license
 | ||||
| // that can be found in the LICENSE file.
 | ||||
| module time | ||||
| 
 | ||||
| struct C.tm { | ||||
| 	tm_year int | ||||
| 	tm_mon  int | ||||
| 	tm_mday int | ||||
| 	tm_hour int | ||||
| 	tm_min  int | ||||
| 	tm_sec  int | ||||
| 	//tm_gmtoff int // seconds
 | ||||
| } | ||||
| 
 | ||||
| pub fn convert_ctime(t tm) Time { | ||||
| 	return Time{ | ||||
| 		year: t.tm_year + 1900 | ||||
| 		month: t.tm_mon + 1 | ||||
| 		day: t.tm_mday | ||||
| 		hour: t.tm_hour | ||||
| 		minute: t.tm_min | ||||
| 		second: t.tm_sec | ||||
| 		unix: C.mktime(&t) | ||||
| 	}//.add_seconds(t.tm_gmtoff)
 | ||||
| } | ||||
| 
 | ||||
|  | @ -282,11 +282,9 @@ pub fn (p mut Parser) call_expr() (ast.CallExpr,types.Type) { | |||
| 		if p.tok.kind == .comma { | ||||
| 			p.error('too many arguments in call to `$fn_name`') | ||||
| 		} | ||||
| 		// }else{
 | ||||
| 		// p.error('unknown function `$fn_name`')
 | ||||
| 	} | ||||
| 	// else{
 | ||||
| 	// p.error('unknown function `$fn_name`')
 | ||||
| 	// }
 | ||||
| 	// exit(0)
 | ||||
| 	p.check(.rpar) | ||||
| 	node := ast.CallExpr{ | ||||
| 		name: fn_name | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue