[gbrainy] Use better time formatting and use mm:ss if hour is 0
- From: Jordi Mas <jmas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gbrainy] Use better time formatting and use mm:ss if hour is 0
- Date: Sun, 19 Jun 2011 21:02:51 +0000 (UTC)
commit a49ca4da66c47b8a5963258325994071e3adc0eb
Author: Jordi Mas <jmas softcatala org>
Date: Sun Jun 19 23:02:19 2011 +0200
Use better time formatting and use mm:ss if hour is 0
src/Core/Main/GameSession.cs | 15 +++++++--------
1 files changed, 7 insertions(+), 8 deletions(-)
---
diff --git a/src/Core/Main/GameSession.cs b/src/Core/Main/GameSession.cs
index f9a8066..cfcb616 100644
--- a/src/Core/Main/GameSession.cs
+++ b/src/Core/Main/GameSession.cs
@@ -113,9 +113,8 @@ namespace gbrainy.Core.Main
set {game_manager.Difficulty = value; }
}
- public TimeSpan GameTime {
- get {return game_time; }
- set {game_time = value; }
+ public string GameTime {
+ get { return TimeSpanToStr (game_time);}
}
public bool Paused {
@@ -327,12 +326,12 @@ namespace gbrainy.Core.Main
static private string TimeSpanToStr (TimeSpan time)
{
- string fmt = time.ToString ();
- int i = fmt.IndexOf ('.');
- if (i > 0 && fmt.Length - i > 2)
- fmt = fmt.Substring (0, i);
+ DateTime dtime;
- return fmt;
+ // Convert it to DateTime to be able to use CultureSensitive formatting
+ dtime = new DateTime (1970, 1, 1, time.Hours, time.Minutes, time.Seconds);
+
+ return dtime.Hour > 0 ? dtime.ToString ("hh:mm:ss") : dtime.ToString ("mm:ss");
}
public void GameUpdateUIElement (object obj, UpdateUIStateEventArgs args)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]