Solved

how to check the current dat versus install date

Posted on 2011-03-12
2
469 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
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 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 …

808 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