From 7ffe5ff169bd9e6fada19bec122ad1e28f505f83 Mon Sep 17 00:00:00 2001 From: gambas Date: Tue, 7 May 2019 23:11:23 +0200 Subject: [PATCH] Date.IsWeekEnd() is a new method that returns if a date is a week end. [GB.UTIL] * NEW: Date.IsWeekEnd() is a new method that returns if a date is a week end. --- comp/src/gb.util/.component | 2 +- comp/src/gb.util/.project | 2 +- comp/src/gb.util/.src/Date.module | 15 +++++++++++---- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/comp/src/gb.util/.component b/comp/src/gb.util/.component index a711f5d56..e095780d6 100644 --- a/comp/src/gb.util/.component +++ b/comp/src/gb.util/.component @@ -1,4 +1,4 @@ [Component] Key=gb.util -Version=3.12.90 +Version=3.13.90 State=1 diff --git a/comp/src/gb.util/.project b/comp/src/gb.util/.project index f55263f0c..b8b2c032a 100644 --- a/comp/src/gb.util/.project +++ b/comp/src/gb.util/.project @@ -1,7 +1,7 @@ # Gambas Project File 3.0 Title=Gambas utilities Startup=MMain -Version=3.12.90 +Version=3.13.90 VersionFile=1 TabSize=2 Language=fr diff --git a/comp/src/gb.util/.src/Date.module b/comp/src/gb.util/.src/Date.module index ee0718539..89cec6e1b 100644 --- a/comp/src/gb.util/.src/Date.module +++ b/comp/src/gb.util/.src/Date.module @@ -7,14 +7,14 @@ Private $dEpoch As Date Public Sub ToUnixTime({Date} As Date) As Long - If Not $dEpoch Then $dEpoch = DateAdd(Date(1970, 1, 1), gb.Second, - System.TimeZone) + If Not $dEpoch Then $dEpoch = DateAdd(Date(1970, 1, 1), gb.Second, -System.TimeZone) Return DateDiff($dEpoch, {Date}, gb.Second) End Public Sub FromUnixTime(UnixTime As Long) As Date - If Not $dEpoch Then $dEpoch = DateAdd(Date(1970, 1, 1), gb.Second, - System.TimeZone) + If Not $dEpoch Then $dEpoch = DateAdd(Date(1970, 1, 1), gb.Second, -System.TimeZone) Return $dEpoch + UnixTime / 86400 End @@ -80,9 +80,9 @@ Private Sub GetRFC822Zone(sZone As String) As Float Case "PST" fZone = -8 Case Like "[A-I]" - fZone = - (Asc(sZone) - 64) + fZone = -(Asc(sZone) - 64) Case Like "[J-M]" - fZone = - (Asc(sZone) - 65) + fZone = -(Asc(sZone) - 65) Case Like "[N-Y]" fZone = Asc(sZone) - 77 Case Like "[+-][0-1][0-9][0-5][0-9]" @@ -152,3 +152,10 @@ Catch Error.Raise("Not a RFC822 date format") End + +Public Sub IsWeekEnd({Date} As Date) As Boolean + + Dim iDay As Integer = WeekDay({Date}) + If iDay = gb.Sunday Or If iDay = gb.Saturday Then Return True + +End