Jul 27

1.Required for windows

    Python 2.5.x

    GAE SDK 1.1.5

2.create a directory named "helloworld" and create the files below in the directory.

(1)app.yaml

    application: marshluca
    version: 1
    runtime: python
    api_version: 1

    handlers:
     -url: /.*
     script: helloworld.py

(2)helloworld.py

    print 'Content-Type: text/plain'
    print ''
    print 'Hello, GAE and Hello Python!'

3.dev_appserver.py helloworld/

4.appcfg.py update helloworld/

5.visit the url http://marshluca.appspot.com/ and http://localhost:8080/

 

Jul 27

 

require 'rubygems'
require 'date'
require 'time'

def format_time(input)
    now = DateTime.parse(Time.now.to_s)
    get = DateTime.parse(input.to_s)
    d = now - get
    hours,minutes,seconds,frac = DateTime.day_fraction_to_time(d)
    if hours.to_i > 24 * 30
      return "#{hours.to_i.div(24 * 30)}个月前"
    elsif hours.to_i > 24
      return "#{hours.to_i.div(24)}天前"
    elsif hours.to_i >= 1
      return "#{hours}小时#{minutes}分#{seconds}秒前"
    else
      return "#{minutes}分#{seconds}秒前."
    end
end

format("format_time("Tue Jul 21 11:15:03 +0800 2009")")