[datetime_picker] convert to pure library, improve Readme with control details and sample code

master
lauzonhomeschool 2024-06-09 00:19:05 -04:00 committed by GitHub
parent e1ddcca2dd
commit fd4009ae73
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 32 additions and 5 deletions

View File

@ -123,7 +123,6 @@ function showNewMenu(group) {
}
function showEditAlarmMenu(selectedAlarm, alarmIndex, withDate, scroll, group) {
console.log(scroll);
var isNew = alarmIndex === undefined;
var alarm = require("sched").newDefaultAlarm();

View File

@ -1,9 +1,36 @@
# 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: ![datetime with swipe controls](screenshot.png)
## Controls
Swipe to increase or decrease date and time elements. Press button or go back to select shown datetime.
![datetime with numbered swipe controls](screenshot2.png)
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(...

View File

@ -2,15 +2,16 @@
"name": "Datetime picker",
"shortName":"Datetime picker",
"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",
"type":"datetimeinput",
"tags":"datetimeinput",
"supports" : ["BANGLEJS2"],
"supports" : ["BANGLEJS2"],
"provides_modules" : ["datetimeinput"],
"readme": "README.md",
"screenshots" : [ { "url":"screenshot.png" } ],
"storage": [
{"name":"datetimeinput","url":"lib.js"},
{"name":"datetime_picker.app.js","url":"app.js"},
{"name":"datetime_picker.img","url":"app-icon.js","evaluate":true}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB