/src/lib/time/formatter/time_in_english.e
Specman e | 163 lines | 131 code | 6 blank | 26 comment | 3 complexity | 879000074fbb4f55c7a2a1286520a6f5 MD5 | raw file
1-- This file is part of a Liberty Eiffel library. 2-- See the full copyright at the end. 3-- 4class TIME_IN_ENGLISH 5 -- 6 -- The English format class for class TIME. 7 -- 8 9inherit 10 TIME_FORMATTER 11 12create {ANY} 13 default_create, set_time 14 15feature {ANY} 16 day_in (buffer: STRING) 17 local 18 s: STRING 19 do 20 if short_mode then 21 inspect 22 time.week_day 23 when 0 then 24 s := once "Su" 25 when 1 then 26 s := once "Mo" 27 when 2 then 28 s := once "Tu" 29 when 3 then 30 s := once "We" 31 when 4 then 32 s := once "Th" 33 when 5 then 34 s := once "Fr" 35 when 6 then 36 s := once "Sa" 37 end 38 else 39 inspect 40 time.week_day 41 when 0 then 42 s := once "Sunday" 43 when 1 then 44 s := once "Monday" 45 when 2 then 46 s := once "Tuesday" 47 when 3 then 48 s := once "Wednesday" 49 when 4 then 50 s := once "Thursday" 51 when 5 then 52 s := once "Friday" 53 when 6 then 54 s := once "Saturday" 55 end 56 end 57 buffer.append(s) 58 end 59 60 month_in (buffer: STRING) 61 local 62 s: STRING 63 do 64 if short_mode then 65 inspect 66 time.month 67 when 1 then 68 s := once "Jan" 69 when 2 then 70 s := once "Feb" 71 when 3 then 72 s := once "Mar" 73 when 4 then 74 s := once "Apr" 75 when 5 then 76 s := once "May" 77 when 6 then 78 s := once "Jun" 79 when 7 then 80 s := once "Jul" 81 when 8 then 82 s := once "Aug" 83 when 9 then 84 s := once "Sep" 85 when 10 then 86 s := once "Oct" 87 when 11 then 88 s := once "Nov" 89 when 12 then 90 s := once "Dec" 91 end 92 else 93 inspect 94 time.month 95 when 1 then 96 s := once "January" 97 when 2 then 98 s := once "February" 99 when 3 then 100 s := once "March" 101 when 4 then 102 s := once "April" 103 when 5 then 104 s := once "May" 105 when 6 then 106 s := once "June" 107 when 7 then 108 s := once "July" 109 when 8 then 110 s := once "August" 111 when 9 then 112 s := once "September" 113 when 10 then 114 s := once "October" 115 when 11 then 116 s := once "November" 117 when 12 then 118 s := once "December" 119 end 120 end 121 buffer.append(s) 122 end 123 124 append_in (buffer: STRING) 125 do 126 day_in(buffer) 127 buffer.extend(' ') 128 month_in(buffer) 129 buffer.extend(' ') 130 time.day.append_in(buffer) 131 buffer.extend(' ') 132 time.hour.append_in(buffer) 133 buffer.extend(':') 134 time.minute.append_in(buffer) 135 if not short_mode then 136 buffer.extend(':') 137 time.second.append_in(buffer) 138 end 139 buffer.extend(' ') 140 time.year.append_in(buffer) 141 end 142 143end -- class TIME_IN_ENGLISH 144-- 145-- Copyright (C) 2009-2017: by all the people cited in the AUTHORS file. 146-- 147-- Permission is hereby granted, free of charge, to any person obtaining a copy 148-- of this software and associated documentation files (the "Software"), to deal 149-- in the Software without restriction, including without limitation the rights 150-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 151-- copies of the Software, and to permit persons to whom the Software is 152-- furnished to do so, subject to the following conditions: 153-- 154-- The above copyright notice and this permission notice shall be included in 155-- all copies or substantial portions of the Software. 156-- 157-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 158-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 159-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 160-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 161-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 162-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 163-- THE SOFTWARE.