1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

cgen: treat the main module like any other v module

This commit is contained in:
Delyan Angelov
2020-07-01 01:53:53 +03:00
committed by GitHub
parent 81e4d3fd09
commit 78e1127d99
53 changed files with 720 additions and 535 deletions

View File

@@ -48,13 +48,13 @@ pub fn (t Time) md() string {
// - a date string in "MMM D HH:MM" format (24h) for date of current year
// - a date string formatted with format function for other dates
pub fn (t Time) clean() string {
now := time.now()
znow := time.now()
// Today
if t.month == now.month && t.year == now.year && t.day == now.day {
if t.month == znow.month && t.year == znow.year && t.day == znow.day {
return t.get_fmt_time_str(.hhmm24)
}
// This year
if t.year == now.year {
if t.year == znow.year {
return t.get_fmt_str(.space, .hhmm24, .mmmd)
}
return t.format()
@@ -65,13 +65,13 @@ pub fn (t Time) clean() string {
// - a date string in "MMM D HH:MM" format (12h) for date of current year
// - a date string formatted with format function for other dates
pub fn (t Time) clean12() string {
now := time.now()
znow := time.now()
// Today
if t.month == now.month && t.year == now.year && t.day == now.day {
if t.month == znow.month && t.year == znow.year && t.day == znow.day {
return t.get_fmt_time_str(.hhmm12)
}
// This year
if t.year == now.year {
if t.year == znow.year {
return t.get_fmt_str(.space, .hhmm12, .mmmd)
}
return t.format()

View File

@@ -189,8 +189,8 @@ fn since(t Time) int {
// relative returns a string representation of difference between time
// and current time.
pub fn (t Time) relative() string {
now := time.now()
secs := now.unix - t.unix
znow := time.now()
secs := znow.unix - t.unix
if secs <= 30 {
// right now or in the future
// TODO handle time in the future
@@ -227,8 +227,8 @@ pub fn (t Time) relative() string {
}
pub fn (t Time) relative_short() string {
now := time.now()
secs := now.unix - t.unix
znow := time.now()
secs := znow.unix - t.unix
if secs <= 30 {
// right now or in the future
// TODO handle time in the future