Solved

how to check the current dat versus install date

Posted on 2011-03-12
2
462 Views
Last Modified: 2012-06-27
Ok I need some guidance I need to write a couple lines of code that check the current date against the date someone installs my software in the registry ... and when the current date approaches install date plus lets say 2 years ...

so im thinking something like

import time

a =check system date
b=check registry  date
if a < b- 60 days then execute code
else showmodal

can someone suggest if im going tin the right direction and if there is some sample code out there
0
Comment
Question by:dolamitejenkins
2 Comments
 
LVL 16

Accepted Solution

by:
gelonida earned 500 total points
ID: 35117656
Theres multiple ways to do it.

I would save the installation time as timestamp  in the registry.

and then calcoulate the difference.

The time module is good enough for this.

If you wont to determine exactly two years with all the leap year maths, then the datetime module might be better.
import time

def savetimetoregistry():
    """ gets current time as a floating point number
        converted to a string
    """
    now = str(time.mktime(time.gmtime()))
    # here you can store the installation time in the registry 
    # as a string value

def time_since_install():
    # fetch here the time string from the registry
    # install_date =  fetch from registry as string
    install_date = float(install_date)
    now = time.mktime(time.gmtime())
    delta_time_in_seconds = now - install_date
    delta_time_in_days = delta_time_in_seconds / 60 / 60 / 24
    if delta_time_in_days > 100: 
        do_something()

Open in new window

0
 

Author Closing Comment

by:dolamitejenkins
ID: 35123595
thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A set of related code is known to be a Module, it helps us to organize our code logically which is much easier for us to understand and use it. Module is an object with arbitrarily named attributes which can be used in binding and referencing. …
Here I am using Python IDLE(GUI) to write a simple program and save it, so that we can just execute it in future. Because when we write any program and exit from Python then program that we have written will be lost. So for not losing our program we…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now