~ubuntu-branches/ubuntu/oneiric/monodevelop/oneiric

« back to all changes in this revision

Viewing changes to contrib/Sharpen/Sharpen/SimpleDateFormat.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2011-06-27 17:03:13 UTC
  • mto: (1.8.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 54.
  • Revision ID: james.westby@ubuntu.com-20110627170313-6cvz3s19x6e9hqe9
ImportĀ upstreamĀ versionĀ 2.5.92+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
namespace Sharpen
 
2
{
 
3
        using System;
 
4
        using System.Globalization;
 
5
 
 
6
        internal class SimpleDateFormat
 
7
        {
 
8
                string format;
 
9
                TimeZoneInfo timeZone;
 
10
                
 
11
                public SimpleDateFormat (): this ("g")
 
12
                {
 
13
                }
 
14
 
 
15
                public SimpleDateFormat (string format): this (format, CultureInfo.CurrentCulture)
 
16
                {
 
17
                }
 
18
 
 
19
                public SimpleDateFormat (string format, CultureInfo c)
 
20
                {
 
21
                        this.format = format.Replace ("EEE", "ddd");
 
22
                        this.format = this.format.Replace ("Z", "zzz");
 
23
                        this.timeZone = TimeZoneInfo.Local;
 
24
                }
 
25
 
 
26
                public string Format (DateTime date)
 
27
                {
 
28
                        date += timeZone.BaseUtcOffset;
 
29
                        return date.ToString (format);
 
30
                }
 
31
 
 
32
                public string Format (long date)
 
33
                {
 
34
                        return Extensions.MillisToDateTimeOffset (date, (int)timeZone.BaseUtcOffset.TotalMinutes).DateTime.ToString (format);
 
35
                }
 
36
 
 
37
                public void SetTimeZone (TimeZoneInfo timeZone)
 
38
                {
 
39
                        this.timeZone = timeZone;
 
40
                }
 
41
        }
 
42
}