~ubuntu-branches/ubuntu/trusty/libticalcs/trusty-proposed

« back to all changes in this revision

Viewing changes to src/clock.c

  • Committer: Package Import Robot
  • Author(s): Andreas B. Mundt
  • Date: 2013-08-27 19:58:21 UTC
  • mfrom: (2.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20130827195821-biurlicyqb65gj3g
Tags: 1.1.8+dfsg2-2
* Provide original upstream source, but patch away pre-compiled
  binaries to be policy-compliant.
* Remove unnecessary dependency on 'autopoint', use autoreconf.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* Hey EMACS -*- linux-c -*- */
2
 
/* $Id: clock.c 2956 2006-09-24 17:11:22Z roms $ */
 
2
/* $Id$ */
3
3
 
4
4
/*  libticalcs - Ti Calculator library, a part of the TiLP project
5
5
 *  Copyright (C) 1999-2005  Romain Li�vin
12
12
 *  This program is distributed in the hope that it will be useful,
13
13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 
 *  GNU General Public License for more details->
 
15
 *  GNU General Public License for more details.
16
16
 *
17
17
 *  You should have received a copy of the GNU General Public License
18
 
 *  along with this program; if not, write to the Free Software
19
 
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
18
 *  along with this program; if not, write to the Free Software Foundation,
 
19
 *  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
20
 */
21
21
 
22
22
/*
70
70
 **/
71
71
TIEXPORT3 const char *TICALL ticalcs_clock_format2date(CalcModel model, int value)
72
72
{
73
 
  int v;
74
 
 
75
 
  if(tifiles_calc_is_ti9x(model))
76
 
  {
77
 
          if (value < 1)
78
 
                v = 1;
79
 
          else if (value > MAX_FORMAT_89)
80
 
                v = MAX_FORMAT_89;
81
 
          else
82
 
                v = value;
83
 
 
84
 
          return TI_CLOCK_89[v];
85
 
  }
86
 
  else if(tifiles_calc_is_ti8x(model))
87
 
  {
88
 
                if (value < 1)
89
 
                v = 1;
90
 
          else if (value > MAX_FORMAT_84)
91
 
                v = MAX_FORMAT_84;
92
 
          else
93
 
                v = value;
94
 
 
95
 
          return TI_CLOCK_84[v];
96
 
  }
97
 
 
98
 
  return "";
 
73
        int v;
 
74
 
 
75
        if(tifiles_calc_is_ti9x(model))
 
76
        {
 
77
                if (value < 1)
 
78
                        v = 1;
 
79
                else if (value > MAX_FORMAT_89)
 
80
                        v = MAX_FORMAT_89;
 
81
                else
 
82
                        v = value;
 
83
 
 
84
                return TI_CLOCK_89[v];
 
85
        }
 
86
        else if(tifiles_calc_is_ti8x(model))
 
87
        {
 
88
                if (value < 1)
 
89
                        v = 1;
 
90
                else if (value > MAX_FORMAT_84)
 
91
                        v = MAX_FORMAT_84;
 
92
                else
 
93
                        v = value;
 
94
 
 
95
                return TI_CLOCK_84[v];
 
96
        }
 
97
 
 
98
        return "";
99
99
}
100
100
 
101
101
/**
110
110
 **/
111
111
TIEXPORT3 int TICALL ticalcs_clock_date2format(CalcModel model, const char *format)
112
112
{
113
 
  int i = 1;
114
 
 
115
 
  if(tifiles_calc_is_ti9x(model))
116
 
  {
117
 
          for (i = 1; i <= MAX_FORMAT_89; i++) 
118
 
          {
 
113
        int i = 1;
 
114
 
 
115
        if (format == NULL)
 
116
        {
 
117
                ticalcs_critical("ticalcs_clock_date2format: format is NULL");
 
118
                return 0;
 
119
        }
 
120
 
 
121
        if(tifiles_calc_is_ti9x(model))
 
122
        {
 
123
                for (i = 1; i <= MAX_FORMAT_89; i++) 
 
124
                {
119
125
                if (!strcasecmp(TI_CLOCK_89[i], format))
120
 
                  break;
121
 
          }
122
 
          if (i > MAX_FORMAT_89)
123
 
                return 1;
124
 
  }
125
 
  else if(tifiles_calc_is_ti8x(model))
126
 
  {
127
 
          for (i = 1; i <= MAX_FORMAT_84; i++) 
128
 
          {
129
 
                if (!strcasecmp(TI_CLOCK_84[i], format))
130
 
                  break;
131
 
          }
132
 
          if (i > MAX_FORMAT_84)
133
 
                return 1;
134
 
  }
 
126
                        break;
 
127
                }
 
128
                if (i > MAX_FORMAT_89)
 
129
                        return 1;
 
130
        }
 
131
        else if(tifiles_calc_is_ti8x(model))
 
132
        {
 
133
                for (i = 1; i <= MAX_FORMAT_84; i++) 
 
134
                {
 
135
                        if (!strcasecmp(TI_CLOCK_84[i], format))
 
136
                        break;
 
137
                }
 
138
                if (i > MAX_FORMAT_84)
 
139
                        return 1;
 
140
        }
135
141
 
136
 
  return i;
 
142
        return i;
137
143
}
138
144
 
139
145
/**
147
153
 **/
148
154
TIEXPORT3 int TICALL ticalcs_clock_show(CalcModel model, CalcClock* s)
149
155
{
150
 
        ticalcs_info("Date: %02i/%02i/%02i", s->day, s->month, s->year);
151
 
        ticalcs_info("Time: %02i/%02i/%02i", s->hours, s->minutes, s->seconds);
152
 
        ticalcs_info("Time format: %02i", s->time_format);
153
 
        ticalcs_info("Date format: %s", ticalcs_clock_format2date(model, s->date_format));
 
156
        if (s != NULL)
 
157
        {
 
158
                ticalcs_info("Date: %02i/%02i/%02i", s->day, s->month, s->year);
 
159
                ticalcs_info("Time: %02i/%02i/%02i", s->hours, s->minutes, s->seconds);
 
160
                ticalcs_info("Time format: %02i", s->time_format);
 
161
                ticalcs_info("Date format: %s", ticalcs_clock_format2date(model, s->date_format));
 
162
        }
154
163
 
155
164
        return 0;
156
165
}