Vlue

Basic Real Time Locale Version

Jul 7th, 2014
133
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Basic Real Time (System Time) Locale Version
  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. RT_MONTHS = ["janvier","fevrier","mars","avril","mai","juin","juillet",
  52.               "aout","septembre","octobre","novembre","decembre"]
  53. RT_DAYS = ["lundi","mardi","mercredi","jeudi","vendridi","samedi","dimanche"]
  54.  
  55. module RTime
  56.   #Functions, explained above#
  57.   def self.fulltime
  58.     return Time.now.strftime(month(true) + ", " + day(true) + " %-d %Y %l:%M")
  59.   end
  60.   def self.time(military = true, full = true)
  61.     return Time.now.strftime("%k:%M:%S") if military and full
  62.     return Time.now.strftime("%k:%M") if military
  63.     return Time.now.strftime("%l:%M:%S %p") if full
  64.     return Time.now.strftime("%l:%M %p")
  65.   end
  66.   def self.year
  67.     return Time.now.year
  68.   end
  69.   def self.month(name = false, abbr = false)
  70.     return Time.now.month if name == false
  71.     if abbr then return Time.now.strftime("%b") else return RT_MONTHS[month-1] end
  72.   end
  73.   def self.day(name = false, abbr = false)
  74.     return Time.now.day if name == false
  75.     if abbr then return Time.now.strftime("%a") else return RT_DAYS[dayweek-1] end
  76.   end
  77.   def self.dayweek
  78.     return Time.now.wday
  79.   end
  80.   def self.hour(military = true)
  81.     return Time.now.hour if military
  82.     if Time.now.hour > 12 then return (Time.now.hour - 12) else return Time.now.hour end
  83.   end
  84.   def self.minute
  85.     return Time.now.min
  86.   end
  87.   def self.second
  88.     if Time.now.sec == 60 then return 0 else return Time.now.sec end
  89.   end
  90. end
  91.  
  92. class Window_Base < Window
  93.   #Alias of convert, to include Rtime escape characters
  94.   alias real_time_convert_escape_characters convert_escape_characters
  95.   def convert_escape_characters(text)
  96.     result = real_time_convert_escape_characters(text)
  97.     result.gsub!(/\eRT\[FT]/) { RTime::fulltime }
  98.     result.gsub!(/\eRT\[Tm]/) { RTime::time(true, false) }
  99.     result.gsub!(/\eRT\[T]/) { RTime::time(false, false) }
  100.     result.gsub!(/\eRT\[Y]/) { RTime::year }
  101.     result.gsub!(/\eRT\[N]/) { RTime::month }
  102.     result.gsub!(/\eRT\[n]/) { RTime::month(true) }
  103.     result.gsub!(/\eRT\[D]/) { RTime::day }
  104.     result.gsub!(/\eRT\[d]/) { RTime::day(true) }
  105.     result.gsub!(/\eRT\[H]/) { RTime::hour(false) }
  106.     result.gsub!(/\eRT\[h]/) { RTime::hour }
  107.     result.gsub!(/\eRT\[m]/) { RTime::minute }
  108.     result.gsub!(/\eRT\[s]/) { RTime::second }
  109.     result
  110.   end
  111. 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.

×