Solved

how to check the current dat versus install date

Posted on 2011-03-12
2
450 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
Comment Utility
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
Comment Utility
thanks
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Python Script 1 66
SPSS Output Table Formatting 3 70
linux / python expert needed 3 79
Python output problem 10 49
Installing Python 2.7.3 version on Windows operating system For installing Python first we need to download Python's latest version from URL" www.python.org " You can also get information on Python scripting language from the above mentioned we…
Introduction On September 29, 2012, the Python 3.3.0 was released; nothing extremely unexpected,  yet another, better version of Python. But, if you work in Microsoft Windows, you should notice that the Python Launcher for Windows was introduced wi…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
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…

744 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

18 Experts available now in Live!

Get 1:1 Help Now