2 * Asterisk -- An open source telephony toolkit.
4 * Copyright (c) 2003, 2006 Tilghman Lesher. All rights reserved.
5 * Copyright (c) 2006 Digium, Inc.
7 * Tilghman Lesher <app_sayunixtime__200309@the-tilghman.com>
9 * This code is released by the author with no restrictions on usage.
11 * See http://www.asterisk.org for more information about
12 * the Asterisk project. Please do not directly contact
13 * any of the maintainers of this project for assistance;
14 * the project provides a web site, mailing lists and IRC
15 * channels for your use.
21 * \brief SayUnixTime application
23 * \author Tilghman Lesher <app_sayunixtime__200309@the-tilghman.com>
25 * \ingroup applications
30 ASTERISK_FILE_VERSION(__FILE__
, "$Revision$")
32 #include "asterisk/file.h"
33 #include "asterisk/channel.h"
34 #include "asterisk/pbx.h"
35 #include "asterisk/module.h"
36 #include "asterisk/say.h"
37 #include "asterisk/app.h"
39 static char *app_sayunixtime
= "SayUnixTime";
40 static char *app_datetime
= "DateTime";
42 static char *sayunixtime_synopsis
= "Says a specified time in a custom format";
44 static char *sayunixtime_descrip
=
45 "SayUnixTime([unixtime][,[timezone][,format]])\n"
46 " unixtime - time, in seconds since Jan 1, 1970. May be negative.\n"
48 " timezone - timezone, see /usr/share/zoneinfo for a list.\n"
49 " defaults to machine default.\n"
50 " format - a format the time is to be said in. See voicemail.conf.\n"
51 " defaults to \"ABdY 'digits/at' IMp\"\n";
52 static char *datetime_descrip
=
53 "DateTime([unixtime][,[timezone][,format]])\n"
54 " unixtime - time, in seconds since Jan 1, 1970. May be negative.\n"
56 " timezone - timezone, see /usr/share/zoneinfo for a list.\n"
57 " defaults to machine default.\n"
58 " format: - a format the time is to be said in. See voicemail.conf.\n"
59 " defaults to \"ABdY 'digits/at' IMp\"\n";
62 static int sayunixtime_exec(struct ast_channel
*chan
, void *data
)
64 AST_DECLARE_APP_ARGS(args
,
66 AST_APP_ARG(timezone
);
76 parse
= ast_strdupa(data
);
78 AST_STANDARD_APP_ARGS(args
, parse
);
80 ast_get_time_t(args
.timeval
, &unixtime
, time(NULL
), NULL
);
82 if (chan
->_state
!= AST_STATE_UP
)
83 res
= ast_answer(chan
);
86 res
= ast_say_date_with_format(chan
, unixtime
, AST_DIGIT_ANY
,
87 chan
->language
, args
.format
, args
.timezone
);
92 static int unload_module(void)
96 res
= ast_unregister_application(app_sayunixtime
);
97 res
|= ast_unregister_application(app_datetime
);
102 static int load_module(void)
106 res
= ast_register_application(app_sayunixtime
, sayunixtime_exec
, sayunixtime_synopsis
, sayunixtime_descrip
);
107 res
|= ast_register_application(app_datetime
, sayunixtime_exec
, sayunixtime_synopsis
, datetime_descrip
);
112 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY
, "Say time");