Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

how to check the current dat versus install date

Posted on 2011-03-12
2
Medium Priority
?
497 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 2000 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

"The time has come," the Walrus said, "To talk of many things: Of sets--and lists--and dictionaries-- Of variable kinks-- And why you see it changing not-- And why so strange are strings." This part describes how variables and references (see …
Sequence is something that used to store data in it in very simple words. Let us just create a list first. To create a list first of all we need to give a name to our list which I have taken as “COURSE” followed by equals sign and finally enclosed …
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 modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…

704 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