Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ LocalizedDuration()

static string Terraria.Lang.LocalizedDuration ( TimeSpan time,
bool abbreviated,
bool showAllAvailableUnits )
inlinestatic

Definition at line 1136 of file Lang.cs.

1137 {
1138 string text = "";
1139 abbreviated |= !GameCulture.FromCultureName(GameCulture.CultureName.English).IsActive;
1140 if (time.Days > 0)
1141 {
1142 int num = time.Days;
1143 if (!showAllAvailableUnits && time > TimeSpan.FromDays(1.0))
1144 {
1145 num++;
1146 }
1147 text = text + num + (abbreviated ? (" " + Language.GetTextValue("Misc.ShortDays")) : ((num == 1) ? " day" : " days"));
1148 if (!showAllAvailableUnits)
1149 {
1150 return text;
1151 }
1152 text += " ";
1153 }
1154 if (time.Hours > 0)
1155 {
1156 int num2 = time.Hours;
1157 if (!showAllAvailableUnits && time > TimeSpan.FromHours(1.0))
1158 {
1159 num2++;
1160 }
1161 text = text + num2 + (abbreviated ? (" " + Language.GetTextValue("Misc.ShortHours")) : ((num2 == 1) ? " hour" : " hours"));
1162 if (!showAllAvailableUnits)
1163 {
1164 return text;
1165 }
1166 text += " ";
1167 }
1168 if (time.Minutes > 0)
1169 {
1170 int num3 = time.Minutes;
1171 if (!showAllAvailableUnits && time > TimeSpan.FromMinutes(1.0))
1172 {
1173 num3++;
1174 }
1175 text = text + num3 + (abbreviated ? (" " + Language.GetTextValue("Misc.ShortMinutes")) : ((num3 == 1) ? " minute" : " minutes"));
1176 if (!showAllAvailableUnits)
1177 {
1178 return text;
1179 }
1180 text += " ";
1181 }
1182 return text + time.Seconds + (abbreviated ? (" " + Language.GetTextValue("Misc.ShortSeconds")) : ((time.Seconds == 1) ? " second" : " seconds"));
1183 }
static GameCulture FromCultureName(CultureName name)
static string GetTextValue(string key)
Definition Language.cs:15
static TimeSpan FromDays(double value)
Definition TimeSpan.cs:162
static TimeSpan FromHours(double value)
Definition TimeSpan.cs:200
static TimeSpan FromMinutes(double value)
Definition TimeSpan.cs:233

References System.TimeSpan.Days, Terraria.Localization.GameCulture.FromCultureName(), System.TimeSpan.FromDays(), System.TimeSpan.FromHours(), System.TimeSpan.FromMinutes(), Terraria.Localization.Language.GetTextValue(), System.TimeSpan.Hours, System.TimeSpan.Minutes, and System.text.

Referenced by Terraria.Main.DrawBuffIcon(), and Terraria.Main.DrawMap().