Vlue

Basic Real Time

Aug 5th, 2012
4,596
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Basic Real Time (System Time)
  2. #----------#
  3. #Features: Provides a series of functions and escape characters to incorporate
  4. #   system time into games.
  5. #
  6. #Usage:   Within Script and Conditional Branches:
  7. #   RTime::fulltime    - returns date, year, and time in one string
  8. #   RTime::time(m, f)  - returns time, m flag is for 24 hour time
  9. # f flag is to include seconds
  10. #   RTime::year    - returns the current year
  11. #   RTime::month(n, a) - returns the current month
  12. #   n flag true, shows month name over number
  13. #   a flag toggles abbreviation i.e "Jan"
  14. #   RTime::day(n, a)   - returns the day of the month
  15. #   n flag true, shows day of the week
  16. #   a flag toggles abbreviation i.e "Fri"
  17. #   RTime::dayweek - returns the day as an integer (Sunday = 0 ..)
  18. #   RTime::hour(m) - returns the current hour, m flag for 24 hour
  19. #   RTime::minute  - returns the current minute
  20. #   RTime::second  - returns the current second
  21. #
  22. #  Within message boxes:
  23. #   \RT[FT]    - replaced by full time
  24. #   \RT[Tm]    - replaced by system time(24 hour)
  25. #   \RT[T] - replaced by system time(am/pm)
  26. #   \RT[Y] - replaced by current year
  27. #   \RT[N] - replaced by current month, integer
  28. #   \RT[n] - replaced by current month, name
  29. #   \RT[D] - replaced by current day of the month
  30. #   \RT[d] - replaced by current day of the week
  31. #   \RT[H] - replaced by current hour(am/pm)
  32. #   \RT[h] - replaced by current hour(24 hour)
  33. #   \RT[m] - replaced by current minute
  34. #   \RT[s] - replaced by current second
  35. #
  36. #Examples: "Why \N[1], it's currently the year \RT[Y]!"
  37. #   RTime::dayweek == 5 /* Within conditional branch, returns true if it's Friday */
  38. #   Rtime::time(true, false)
  39. #
  40. #----------#
  41. #-- Script by: V.M of D.T
  42. #
  43. #- Questions or comments can be:
  44. #    given by email: sumptuaryspade@live.ca
  45. #    provided on facebook: http://www.facebook.com/DaimoniousTailsGames
  46. #   All my other scripts and projects can be found here: http://daimonioustails.weebly.com/
  47. #
  48. #--- Free to use in any project, commercial or non-commercial, with credit given
  49. # - - Though a donation's always a nice way to say thank you~ (I also accept actual thank you's)
  50.  
  51. module RTime
  52.   #Functions, explained above#
  53.   def self.fulltime
  54.     return Time.now.strftime("%A, %B %-d, %Y %l:%M")
  55.   end
  56.   def self.time(military = true, full = true)
  57.     return Time.now.strftime("%k:%M:%S") if military and full
  58.     return Time.now.strftime("%k:%M") if military
  59.     return Time.now.strftime("%l:%M:%S %p") if full
  60.     return Time.now.strftime("%l:%M %p")
  61.   end
  62.   def self.year
  63.     return Time.now.year
  64.   end
  65.   def self.month(name = false, abbr = false)
  66.     return Time.now.month if name == false
  67.     if abbr then return Time.now.strftime("%b") else return Time.now.strftime("%B") end
  68.   end
  69.   def self.day(name = false, abbr = false)
  70.     return Time.now.day if name == false
  71.     if abbr then return Time.now.strftime("%a") else return Time.now.strftime("%A") end
  72.   end
  73.   def self.dayweek
  74.     return Time.now.wday
  75.   end
  76.   def self.hour(military = true)
  77.     return Time.now.hour if military
  78.     if Time.now.hour > 12 then return (Time.now.hour - 12) else return Time.now.hour end
  79.   end
  80.   def self.minute
  81.     return Time.now.min
  82.   end
  83.   def self.second
  84.     if Time.now.sec == 60 then return 0 else return Time.now.sec end
  85.   end
  86. end
  87.  
  88. class Window_Base < Window
  89.   #Alias of convert, to include Rtime escape characters
  90.   alias real_time_convert_escape_characters convert_escape_characters
  91.   def convert_escape_characters(text)
  92.     result = real_time_convert_escape_characters(text)
  93.     result.gsub!(/\eRT\[FT]/) { RTime::fulltime }
  94.     result.gsub!(/\eRT\[Tm]/) { RTime::time(true, false) }
  95.     result.gsub!(/\eRT\[T]/) { RTime::time(false, false) }
  96.     result.gsub!(/\eRT\[Y]/) { RTime::year }
  97.     result.gsub!(/\eRT\[N]/) { RTime::month }
  98.     result.gsub!(/\eRT\[n]/) { RTime::month(true) }
  99.     result.gsub!(/\eRT\[D]/) { RTime::day }
  100.     result.gsub!(/\eRT\[d]/) { RTime::day(true) }
  101.     result.gsub!(/\eRT\[H]/) { RTime::hour(false) }
  102.     result.gsub!(/\eRT\[h]/) { RTime::hour }
  103.     result.gsub!(/\eRT\[m]/) { RTime::minute }
  104.     result.gsub!(/\eRT\[s]/) { RTime::second }
  105.     result
  106.   end
  107. end
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×