time: calc_unix => unix_time
							parent
							
								
									e78b97652b
								
							
						
					
					
						commit
						2efc37947d
					
				| 
						 | 
					@ -2,7 +2,7 @@ import time.misc as tmisc
 | 
				
			||||||
// using a manual temporary intermediate variable should always work:
 | 
					// using a manual temporary intermediate variable should always work:
 | 
				
			||||||
fn test_call_fn_that_requires_reference_with_function_that_returns_a_struct_manual() {
 | 
					fn test_call_fn_that_requires_reference_with_function_that_returns_a_struct_manual() {
 | 
				
			||||||
	t1 := tmisc.random()
 | 
						t1 := tmisc.random()
 | 
				
			||||||
	t2 := t1.calc_unix()
 | 
						t2 := t1.unix_time()
 | 
				
			||||||
	println('res: $t2')
 | 
						println('res: $t2')
 | 
				
			||||||
	assert true
 | 
						assert true
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -11,7 +11,7 @@ fn test_call_fn_that_requires_reference_with_function_that_returns_a_struct_manu
 | 
				
			||||||
// TODO: Fix this.
 | 
					// TODO: Fix this.
 | 
				
			||||||
// v should produce temporary intermediate variables in chained calls:
 | 
					// v should produce temporary intermediate variables in chained calls:
 | 
				
			||||||
fn test_call_fn_that_requires_reference_with_function_that_returns_a_struct_chained(){
 | 
					fn test_call_fn_that_requires_reference_with_function_that_returns_a_struct_chained(){
 | 
				
			||||||
	res := (tmisc.random().calc_unix())
 | 
						res := (tmisc.random().unix_time())
 | 
				
			||||||
	println('res: $res')
 | 
						println('res: $res')
 | 
				
			||||||
	assert true
 | 
						assert true
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -95,17 +95,17 @@ pub fn new_time(t Time) Time {
 | 
				
			||||||
		hour: t.hour
 | 
							hour: t.hour
 | 
				
			||||||
		minute: t.minute
 | 
							minute: t.minute
 | 
				
			||||||
		second: t.second
 | 
							second: t.second
 | 
				
			||||||
		unix: t.calc_unix()
 | 
							unix: t.unix_time()
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	// TODO Use the syntax below when it works with reserved keywords like `unix`
 | 
						// TODO Use the syntax below when it works with reserved keywords like `unix`
 | 
				
			||||||
	// return {
 | 
						// return {
 | 
				
			||||||
	// 	t |
 | 
						// 	t |
 | 
				
			||||||
	// 	unix:t.calc_unix()
 | 
						// 	unix:t.unix_time()
 | 
				
			||||||
	// }
 | 
						// }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// calc_unix returns Unix time.
 | 
					// unix_time returns Unix time.
 | 
				
			||||||
pub fn (t &Time) calc_unix() int {
 | 
					pub fn (t &Time) unix_time() int {
 | 
				
			||||||
	if t.unix != 0 {
 | 
						if t.unix != 0 {
 | 
				
			||||||
		return t.unix
 | 
							return t.unix
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue