Solved

how to check the current dat versus install date

Posted on 2011-03-12
2
487 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 17

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
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 if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
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…
Suggested Courses

751 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