Jump to content

Recommended Posts

Posted (edited)

Hi there,

I'm wanting to put in a line that determines whether the current date is passed the 'expired' date which is included in the code.

I have the idea? But am not overly familiar in determining all the functions in the date.au3 extension.

#include <Date.au3>
Local $expdate = _SetDate(01, 02, 2016)
Local $datediff = _DateDiff('D', $expdate, _NowCalc())
If $datediff = 0 Then
    MsgBox(0, "Expired", "Sorry, this program has expired, contact me for an extension.", 15)
    Exit
EndIf

 

And tried this:

#include <Date.au3>
Local $currdate = _Date_Time_GetSystemTime()
Local $expdate = _SetDate(01, 02, 2015)
If $currdate > $expdate Then
    MsgBox(0, "Expired", "Sorry, this program has expired, contact me for an extension.", 15)

    Exit
EndIf

 

Any assistance would be very appreciated.

 

Thanks

Edited by MrCheese
Posted (edited)

_SetDate changes the system date.

You can put the date as string directly in _DateDiff :

#include <Date.au3>

$endDate = "2016/02/01"

Local $datediff = _DateDiff('D', $endDate, _NowCalc() )
If $datediff > 0 Then
    MsgBox(0, "Expired", "Sorry, this program has expired, contact ....@gmail.com for an extension.", 15)
    Exit
EndIf

Note that it is possible do use this :

$endDate = "20160201"
If $endDate < (@YEAR & @MON & @MDAY) Then
    MsgBox(0, "Expired", "Sorry, this program has expired, contact .....@gmail.com for an extension.", 15)
    Exit
EndIf


Edit : sorry, my code was wrong...

Edited by Jos
removed email
Posted

it is common that _DateDiff() sees the earlier date first, so better use:

Local $datediff = _DateDiff('D', $expdate, _NowCalc()) ; earlier date first

the above is not mandatory, but it makes more sense, because the diff can be negative. so most important - the condition must be:

If $datediff <= 0 Then

because if it's only = 0 (equals to zero) rather than <= 0 (equals or smaller than zero) then when your users run your program few days after the expiration date, it "becomes" functional again...

this is addressed in the 2nd snippet of the post by @@jguinch (but not the first).

 

and finally, the obvious word of advice - this type of obsolescence method is not very difficult to overcome.

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

WinPose - simultaneous fluent move and resize

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

Magic Math - a math puzzle

Demos:

Title Bar Menu - click the window title to pop-up a menu

 

Posted (edited)

Hi guys,

Thank you heaps for your input. I went with this code:

 

$endDate = "20160201"
If $endDate < (@YEAR & @MON & @MDAY) Then
    MsgBox(0, "Expired", "Sorry, this program has expired, contact ....@gmail.com for an extension.", 15)
    Exit
EndIf

Any concerns with that?

Edited by Jos
Removed Email

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...