[datetime_picker] convert to pure library, improve Readme with control details and sample code
parent
e1ddcca2dd
commit
fd4009ae73
|
|
@ -123,7 +123,6 @@ function showNewMenu(group) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function showEditAlarmMenu(selectedAlarm, alarmIndex, withDate, scroll, group) {
|
function showEditAlarmMenu(selectedAlarm, alarmIndex, withDate, scroll, group) {
|
||||||
console.log(scroll);
|
|
||||||
var isNew = alarmIndex === undefined;
|
var isNew = alarmIndex === undefined;
|
||||||
|
|
||||||
var alarm = require("sched").newDefaultAlarm();
|
var alarm = require("sched").newDefaultAlarm();
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,36 @@
|
||||||
# App Name
|
# App Name
|
||||||
|
|
||||||
Datetime Picker allows to swipe along the bars to select date and time elements, e.g. for the datetime of Events in the Alarm App. As a standalone app, it allows to see the weekday of a given date and, once a datetime is selected, the number of days and time between that datetime and now.
|
Datetime Picker allows to swipe along the bars to select date and time elements, e.g. for the datetime of Events in the Alarm App.
|
||||||
|
|
||||||
Screenshot: 
|
Screenshot: 
|
||||||
|
|
||||||
## Controls
|
## Controls
|
||||||
|
|
||||||
Swipe to increase or decrease date and time elements. Press button or go back to select shown datetime.
|
Swipe to increase or decrease date and time elements. Press button or go back to select shown datetime.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
1. Year: swipe up to increase, down to decrease
|
||||||
|
2. Month: swipe right to increase, left to decrease
|
||||||
|
3. Day: swipe up to increase, down to decrease
|
||||||
|
4. Week: swipe up to increase week (same day next week), down to decrease (same day previous week)
|
||||||
|
5. Weekday: swipe right to increase, left to decrease (basically the same effect as 3, but with a focus on the weekday)
|
||||||
|
6. Hour: swipe right to increase, left to decrease
|
||||||
|
7. Minutes: swipe right to increase, left to decrease
|
||||||
|
8. 15 minutes: 00, 15, 30 or 45 minutes; swipe up to increase, down to decrease; wrap-around i.e. goes back to 00 after increasing from 45
|
||||||
|
|
||||||
|
## How to use it in code
|
||||||
|
|
||||||
|
Sample code which would show a prompt with the number of days and hours between now and the selected datetime:
|
||||||
|
|
||||||
|
require("datetimeinput").input().then(result => {
|
||||||
|
E.showPrompt(`${result}\n\n${require("time_utils").formatDuration(Math.abs(result-Date.now()))}`, {buttons:{"Ok":true}}).then(function() {
|
||||||
|
load();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
To set the initial value, pass a Date object named _datetime_, e.g. for today at 9:30 :
|
||||||
|
|
||||||
|
var datetime = new Date();
|
||||||
|
datetime.setHours(9, 30);
|
||||||
|
require("datetimeinput").input({datetime}).then(...
|
||||||
|
|
@ -2,15 +2,16 @@
|
||||||
"name": "Datetime picker",
|
"name": "Datetime picker",
|
||||||
"shortName":"Datetime picker",
|
"shortName":"Datetime picker",
|
||||||
"version":"0.01",
|
"version":"0.01",
|
||||||
"description": "Allows to pick a date and time by swiping.",
|
"description": "A library that allows to pick a date and time by swiping.",
|
||||||
"icon":"app.png",
|
"icon":"app.png",
|
||||||
|
"type":"datetimeinput",
|
||||||
"tags":"datetimeinput",
|
"tags":"datetimeinput",
|
||||||
"supports" : ["BANGLEJS2"],
|
"supports" : ["BANGLEJS2"],
|
||||||
|
"provides_modules" : ["datetimeinput"],
|
||||||
"readme": "README.md",
|
"readme": "README.md",
|
||||||
"screenshots" : [ { "url":"screenshot.png" } ],
|
"screenshots" : [ { "url":"screenshot.png" } ],
|
||||||
"storage": [
|
"storage": [
|
||||||
{"name":"datetimeinput","url":"lib.js"},
|
{"name":"datetimeinput","url":"lib.js"},
|
||||||
{"name":"datetime_picker.app.js","url":"app.js"},
|
|
||||||
{"name":"datetime_picker.img","url":"app-icon.js","evaluate":true}
|
{"name":"datetime_picker.img","url":"app-icon.js","evaluate":true}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 3.9 KiB |
Loading…
Reference in New Issue