PC SOFT
DEPOT EN LIGNE
POUR WINDEVWEBDEV ET WINDEV MOBILE

WD Management of dates
Publié par Boller
dans la catégorie Outils
Nouveautés



Description
WD Management of dates

// Update the different information
UPDYearManagement()
UPDMonthManagement()
UPDWeekManagement()
UPDSimpleManagement()

//------------------------------------------------

// Syntax:
//UPDYearManagement ()
//
// This function updates the information according to the year entered by the user
PROCEDURE UPDYearManagement()

sResult is string
dStartDate, dEndDate are Date
nNbDays is int

// Retrieve the first day and the last day of the year in letters
sResult = "First day of the year " + TXT_YEAR + " is " + FirstDayOfMonthInLetter(01,TXT_YEAR) +". (WLanguage FirstDayOfMonth function)"+ CR +CR
sResult += "Last day of the year " + TXT_YEAR + " is " + LastDayOfMonthInLetter(12,TXT_YEAR)+". (WLanguage LastDayOfMonth function)" + CR + CR


// Is the year a leap year?
IF IsLeap(TXT_YEAR) = True THEN
sResult += "The year " + TXT_YEAR + " is a leap year. (IsLeap function)" + CR +CR
ELSE
sResult += "The year " + TXT_YEAR + " is not a leap year. (IsLeap function)"+ CR +CR
END

dStartDate..Day = 01
dStartDate..Month = 01
dStartDate..Year = TXT_YEAR


dEndDate..Month = 12
dEndDate..Day = 31
dEndDate..Year = TXT_YEAR

nNbDays = DateDifference(dStartDate,dEndDate) + 1

sResult += "The year " + TXT_YEAR + " a " +nNbDays+ " days. (WLanguage DateDifference function)" + CR + CR

sResult += "The year " + TXT_YEAR + " a " + WeekNumber(dEndDate) + " weeks (WLanguage WeekNumber function)" + CR + CR


STC_TC_RESULT_YEAR = sResult

//-----------------------------------------------------------------------------------------------

// Syntax:
//UPDMonthManagement ()
//
// This function updates the information according to the month entered by the user

PROCEDURE UPDMonthManagement()

sResult is string


// Retrieve the month in letters
sResult = "The month # " + TXT_MONTHNUM + " corresponds to the month of " + MonthInLetter(TXT_MONTHNUM) + ". (WLanguage DateToMonthInAlpha function or MonthInLetter function)" + CR +CR


// Retrieve the first day and the last day of the month (in letters)
sResult +="First day of the month of " +MonthInLetter(TXT_MONTHNUM) + " is "+ DateToDayInAlpha(FirstDayOfMonth()) + ". (WLanguage FirstDayOfMonth function)" + CR+CR
sResult +="Last day of month of " +MonthInLetter(TXT_MONTHNUM) + " is "+ DateToDayInAlpha(LastDayOfMonth()) + ". (WLanguage LastDayOfMonth function)" + CR+CR

// Retrieve the number of days for the month
sResult += "The month of "+ MonthInLetter(TXT_MONTHNUM) + " a " + NumberDaysInMonth(TXT_MONTHNUM) + " days. (NumberDaysInMonth function)" + CR+CR

// Retrieve the first "Monday" and the last "Monday" of the month
sResult += "The first Monday of the month is the " + FirstDayOfMonthInLetter("Monday",TXT_MONTHNUM) + "/"+TXT_MONTHNUM+"/"+CurrentYear()+". (FirstDayOfMonth function)" + CR + CR
sResult += "The last Monday of the month is " + LastDayOfMonthInLetter("Monday",TXT_MONTHNUM) + "/"+TXT_MONTHNUM+"/"+CurrentYear()+". (LastDayOfMonth function)"

STC_TC_RESULT_MONTH = sResult

//-------------------------------------------------------------

// Syntax:
//UPDWeekManagement ()
//
// This function updates the information according to the week entered by the user
PROCEDURE UPDWeekManagement()


sResult is string
dStartDate is Date
dEndDate is Date


// Retrieve the start date and the end date for week number TXT_WEEK_NUMBER
WeekNumberToDates(TXT_WEEK_NUMBER,dStartDate,dEndDate)


sResult = "Week # " + TXT_WEEK_NUMBER + " of the year " + CurrentYear() + ...
" start on monday " + DateToString(dStartDate,"MM/DD/YYYY") + ...
" and end on sunday " +DateToString(dEndDate,"MM/DD/YYYY") +". (WeekNumberToDate function supplied in the set of procedures named pDates)"+ CR + CR

// Retrieve the month(s) containing the week number TXT_WEEK_NUMBER
IF dStartDate..Month <> dEndDate..Month THEN

sResult += "This week straddles a month " + dStartDate..Month + " (" + MonthInLetter(dStartDate..Month) + ") and " + dEndDate..Month...
+ " (" + MonthInLetter(dEndDate..Month) + ")" + CR + CR
ELSE

sResult += "This week is at least # " + dStartDate..Month + " (" + MonthInLetter(dStartDate..Month) + ")" + CR + CR

END

STC_TC_RESULT_WEEK = sResult

//-------------------------------------------------------------

// Syntax:
//UPDSimpleManagement ()
//
// This function updates the information according to the date entered by the user
PROCEDURE UPDSimpleManagement()

sResult is string // Result that will be displayed
dDate is Date = TXT_SIMPLE_DATE // Current date
sDayNum is string // Caption of day number (to differentiate between 1st, 2nd, 3rd)
nDayNum is int // Number of the day in the week


// Retrieve the day in letters
sResult = "The " + DateToString(TXT_SIMPLE_DATE,"MM/DD/YYYY") + " is " + DateToDayInAlpha(TXT_SIMPLE_DATE) +". (WLanguage DateToDayInAlpha function)" + CR + CR

// Retrieve the day in the week
nDayNum = DateToDay(TXT_SIMPLE_DATE)

// Update the string to display
IF nDayNum = 1 THEN
sDayNum = "1st"
ELSE
sDayNum = nDayNum + "th"
END

sResult += "The " + DateToString(TXT_SIMPLE_DATE,"MM/DD/YYYY") + " is the " + sDayNum + " day of the week (WLanguage DateToDay function)"

// Retrieve the number of the week
sResult += " This day is part of week # "+ WeekNumber(TXT_SIMPLE_DATE) +". (WLanguage WeekNumber function)" + CR+CR

// Email formatting
sResult += StringBuild("With the ""maskEmailDate"" mask, the %1 is formatted as follows: %2", DateToString(TXT_SIMPLE_DATE,"MM/DD/YYYY"),DateToString(TXT_SIMPLE_DATE+Now(),maskEmailDate))

STC_TC_RESULT_SIMPLE = sResult

Illustrations, copies d'écran
none
none
Avis des utilisateurs
(Pour noter la ressource, cliquez sur Ecrire un avis)
Aucun avis ou commentaire ? Soyez le premier !