diff --git a/vlib/time/time.v b/vlib/time/time.v index 971dc9fb38..5944239fa1 100644 --- a/vlib/time/time.v +++ b/vlib/time/time.v @@ -7,7 +7,39 @@ module time import rand const ( - month_days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] + days_string = 'MonTueWedThuFriSatSun' + + month_days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] + months_string = 'JanFebMarAprMayJunJulAugSepOctNovDec' + + // The unsigned zero year for internal calculations. + // Must be 1 mod 400, and times before it will not compute correctly, + // but otherwise can be changed at will. + absolute_zero_year = i64(-292277022399) + + seconds_per_minute = 60 + seconds_per_hour = 60 * seconds_per_minute + seconds_per_day = 24 * seconds_per_hour + seconds_per_week = 7 * seconds_per_day + days_per_400_years = 365*400 + 97 + days_per_100_years = 365*100 + 24 + days_per_4_years = 365*4 + 1 + + days_before = [ + 0, + 31, + 31 + 28, + 31 + 28 + 31, + 31 + 28 + 31 + 30, + 31 + 28 + 31 + 30 + 31, + 31 + 28 + 31 + 30 + 31 + 30, + 31 + 28 + 31 + 30 + 31 + 30 + 31, + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31, + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30, + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31, + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30, + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + 31, + ] ) #include @@ -56,43 +88,6 @@ pub fn random() Time { return time.unix(rand_unix) } -const ( -// The unsigned zero year for internal calculations. - // Must be 1 mod 400, and times before it will not compute correctly, - // but otherwise can be changed at will. - absolute_zero_year = i64(-292277022399) - - seconds_per_minute = 60 - seconds_per_hour = 60 * seconds_per_minute - seconds_per_day = 24 * seconds_per_hour - seconds_per_week = 7 * seconds_per_day - days_per_400_years = 365*400 + 97 - days_per_100_years = 365*100 + 24 - days_per_4_years = 365*4 + 1 - - days_before = [ - 0, - 31, - 31 + 28, - 31 + 28 + 31, - 31 + 28 + 31 + 30, - 31 + 28 + 31 + 30 + 31, - 31 + 28 + 31 + 30 + 31 + 30, - 31 + 28 + 31 + 30 + 31 + 30 + 31, - 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31, - 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30, - 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31, - 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30, - 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + 31, -] - -) - -const ( - months_string = 'JanFebMarAprMayJunJulAugSepOctNovDec' - days_string = 'MonTueWedThuFriSatSun' -) - // Based on Go's time package. // Copyright 2009 The Go Authors.