~cszikszoy/docky/mmv3

« back to all changes in this revision

Viewing changes to Docky.StandardPlugins/Weather/WeatherForecast.cs

  • Committer: Chris S.
  • Date: 2009-10-22 03:23:13 UTC
  • mfrom: (284.1.7 testaddins)
  • Revision ID: chris@szikszoy.com-20091022032313-2s9kikljologdsyt
enable lazy loading of addins

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//  
2
 
//  Copyright (C) 2009 Robert Dyer
3
 
// 
4
 
//  This program is free software: you can redistribute it and/or modify
5
 
//  it under the terms of the GNU General Public License as published by
6
 
//  the Free Software Foundation, either version 3 of the License, or
7
 
//  (at your option) any later version.
8
 
// 
9
 
//  This program is distributed in the hope that it will be useful,
10
 
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 
//  GNU General Public License for more details.
13
 
// 
14
 
//  You should have received a copy of the GNU General Public License
15
 
//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
 
// 
17
 
 
18
 
using System;
19
 
using Mono.Unix;
20
 
 
21
 
namespace WeatherDocklet
22
 
{
23
 
        /// <summary>
24
 
        /// Stores information about one day's weather forecast.
25
 
        /// </summary>
26
 
        public struct WeatherForecast
27
 
        {
28
 
                /// <summary>
29
 
                /// The high value for the forecast day.
30
 
                /// </summary>
31
 
                public int high;
32
 
                
33
 
                /// <summary>
34
 
                /// The low value for the forecast day.
35
 
                /// </summary>
36
 
                public int low;
37
 
                
38
 
                /// <summary>
39
 
                /// The day of the week (3 char string, ex: Mon, Tue, etc).
40
 
                /// </summary>
41
 
                public string dow;
42
 
                
43
 
                /// <summary>
44
 
                /// The condition for the forecast day.
45
 
                /// </summary>
46
 
                public string condition;
47
 
                
48
 
                /// <summary>
49
 
                /// If there is a chance of precipitation.
50
 
                /// </summary>
51
 
                public bool chanceOf;
52
 
                
53
 
                /// <summary>
54
 
                /// An icon name representing the condition for the forecast day.
55
 
                /// </summary>
56
 
                public string image;
57
 
                
58
 
                /// <summary>
59
 
                /// Takes a short name for a day and returns the full name.
60
 
                /// </summary>
61
 
                /// <param name="dow">
62
 
                /// A <see cref="System.string"/> indicating the short name for the day.
63
 
                /// </param>
64
 
                /// <returns>
65
 
                /// A <see cref="System.string"/> of the day's full name.
66
 
                /// </returns>
67
 
                public static string DayName (string dow)
68
 
                {
69
 
                        DayOfWeek day = DayOfWeek.Sunday;
70
 
                        
71
 
                        if (dow.Equals ("Mon"))
72
 
                                day = DayOfWeek.Monday;
73
 
                        else if (dow.Equals ("Tue"))
74
 
                                day = DayOfWeek.Tuesday;
75
 
                        else if (dow.Equals ("Wed"))
76
 
                                day = DayOfWeek.Wednesday;
77
 
                        else if (dow.Equals ("Thu"))
78
 
                                day = DayOfWeek.Thursday;
79
 
                        else if (dow.Equals ("Fri"))
80
 
                                day = DayOfWeek.Friday;
81
 
                        else if (dow.Equals ("Sat"))
82
 
                                day = DayOfWeek.Saturday;
83
 
                        else if (dow.Equals ("Sun"))
84
 
                                day = DayOfWeek.Sunday;
85
 
 
86
 
                        if (DateTime.Now.DayOfWeek == day)
87
 
                                return Catalog.GetString ("Today");
88
 
 
89
 
                        if (DateTime.Now.AddDays (1).DayOfWeek == day)
90
 
                                return Catalog.GetString ("Tomorrow");
91
 
 
92
 
                        return DateTime.Now.AddDays (day - DateTime.Now.DayOfWeek).ToString ("dddd");
93
 
                }
94
 
        }
95
 
}