/src/lib/time/time_formatter.e

http://github.com/tybor/Liberty · Specman e · 89 lines · 45 code · 12 blank · 32 comment · 0 complexity · 91a5ab79aff8ac920c0643f5f49aaf9c MD5 · raw file

  1. -- This file is part of a Liberty Eiffel library.
  2. -- See the full copyright at the end.
  3. --
  4. deferred class TIME_FORMATTER
  5. --
  6. -- The polymorphic format class for TIME.
  7. --
  8. insert
  9. TIME_HANDLER
  10. redefine out_in_tagged_out_memory
  11. end
  12. feature {ANY}
  13. time: TIME
  14. -- The corresponding information to display.
  15. set_time (t: TIME)
  16. do
  17. time := t
  18. ensure
  19. time = t
  20. end
  21. short_mode: BOOLEAN
  22. -- Is the formatting mode set to the short (abbreviated) mode ?
  23. set_short_mode (value: BOOLEAN)
  24. do
  25. short_mode := value
  26. ensure
  27. short_mode = value
  28. end
  29. day_in (buffer: STRING)
  30. -- According to the current `short_mode', append in the `buffer'
  31. -- the name of the day.
  32. deferred
  33. end
  34. month_in (buffer: STRING)
  35. -- According to the current `short_mode', append in the `buffer'
  36. -- the name of the month.
  37. deferred
  38. end
  39. frozen to_string: STRING
  40. do
  41. to_string_buffer.clear_count
  42. append_in(to_string_buffer)
  43. Result := to_string_buffer.twin
  44. end
  45. append_in (buffer: STRING)
  46. deferred
  47. end
  48. frozen out_in_tagged_out_memory
  49. do
  50. append_in(tagged_out_memory)
  51. end
  52. feature {}
  53. to_string_buffer: STRING
  54. once
  55. create Result.make(128)
  56. end
  57. end -- class TIME_FORMATTER
  58. --
  59. -- Copyright (C) 2009-2017: by all the people cited in the AUTHORS file.
  60. --
  61. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  62. -- of this software and associated documentation files (the "Software"), to deal
  63. -- in the Software without restriction, including without limitation the rights
  64. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  65. -- copies of the Software, and to permit persons to whom the Software is
  66. -- furnished to do so, subject to the following conditions:
  67. --
  68. -- The above copyright notice and this permission notice shall be included in
  69. -- all copies or substantial portions of the Software.
  70. --
  71. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  72. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  73. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  74. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  75. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  76. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  77. -- THE SOFTWARE.