Is it possible to add custom cases to moment.js 'time from now' - momentjs

Here are the 'time from now' cases and their corresponding output:
The output and the range can be changed, but I'm trying to do something a bit different.
Is it possible to add custom keys, for example if it is less than 5 minutes than show 'Just now'. Or if it is more than 24 hours and the same week then output the day's name, etc.
Thanks!

Related

Render endDate as if they're inclusive

I realise that by design it's intended that fullcalendar endDates are exclusive, but I'm looking for help to work with that given my constraints.
Data stored is simple UK date format:
YYYY-MM-DD
start: 2015-01-18
end: 2015-01-19
I'd like to keep the look of the plain all day events, rather than the timestamped style and I cant just +1 end date as what happens come the end of the month?
I've tried poking through the source js, to remove any -1 corrections in there. That works for my multiday events, but then makes one day events look like two day events.
Scenario. Users select a start date and end date (of their holidays)
So that would be perhaps monday to friday. Users dont select a time, just the date. Naturally they'll select the dates they want for holiday as inclusive.
Expected behaviour.
18/1/2015 - 18/1/2015 would highlight one full day.
18/1/2015 - 19/1/2015 would highlight two full days (inclusive days)
18/1/2015 - 20/1/2015 would highlight three full days (inclusive days)
etc..etc
Actual behaviour.
18/1/2015 - 18/1/2015 will highlight one full day.
18/1/2015 - 19/1/2015 will highlight one full day (exclusive endday)
18/1/2015 - 20/1/2015 will highlight two full days (exclusive endday)
Open to suggestions, fixes, workarounds, dirty hacks.
Thanks
It's possible I'm misunderstanding, but here's a possible solution.
Inside of eventDataTransform (which is called for every event), add a time to each start and end date. Something like
eventDataTransform: function(eventData){
eventData.start.startOf('day');
eventData.start.endOf('day');
}
Thanks to slicedtoad for the hint with eventDataTransform. I just had to find the correct way to actually add 1 to the end date. For any one curious (and I'm not sure I fully understand how it works), but a one day event is still a one day event even though it appears we're add one to the end?
events:
{
url: '<?php echo base_url();?>index.php/jsonfeed',
error: function()
{
alert('error');
},
},
eventDataTransform: function(eventData)
{
eventData.end = moment(eventData.end).add(1, 'days').format();
return eventData;
},

How can I filter by "updated this month" in a view?

I have a view filled with content of stuff that needs to be done every month.
I already have it set up to show everything that fits that parameter, I have one more thing i want it to filter by:
I want it to be able to show only things that have not been edited in the current month. This does not mean within a month.
If today is June 02 I want to
see something that was updated may 31
not something edited june 01
I am able to set it by an exact day, but i don't want to have to change that every month.
I am able to set it by a set amount of time(-1 month), but this will do it within a month instead of within the month
Remove your filter and add a contextual filter: Content: Updated month - Date in the form of MM (01 - 12). & select the option Provide default value to Current Date. This will make sure your view gets content from the current month & not from within a month range.

AppInventor: how to insert DateTime into Google Spreadsheet and show only recent DateTime

I am new to this forum so I hope I asking my question in the right place.
I have a problem inserting a datetime into a Google Spreadsheet from a form created in Appinventor2;
In app inventor2 I created a form that fills in a google spreadsheet. Basically I merged the Pizza Party example (http://appinventor.mit.edu/explore/ai2/pizzaparty.html) with this example http://puravidaapps.com/spreadsheet.php to use google spreadsheet instead of fusion table.
the user selects in how many minutes he wants his order and then sees all the orders in a table sorted by delivery time.
Problem A)
Firstly, i want to save the current datetime + the desired delay into the google spreadsheet and sort the table by this new datetime.
1) when i use the block "call clock format time" + "call clock addminutes" the spreadsheet is populated with a text, but then i can't sort the table by delivery datetime. in fact i believe the sorting is done on the number regardless of the am/pm or day of the month. so for example instead of having 4am, 6am, 2pm, 3pm i get : 2pm, 3pm, 4am, 6am.
2) I then tried to remove the block "call clock format time" and in the google form i kept the field format = text
but the google spreadsheet is populated with the following:
java.util.GregorianCalendar[time=1395531335908,areFieldsSet=true,lenient=true,zone=Europe/Dublin,firstDayOfWeek=2,minimalDaysInFirstWeek=4,ERA=1,YEAR=2014,MONTH=2,WEEK_OF_YEAR=12,WEEK_OF_MONTH=4,DAY_OF_MONTH=22,DAY_OF_YEAR=81,DAY_OF_WEEK=7,DAY_OF_WEEK_IN_MONTH=4,AM_PM=1,HOUR=11,HOUR_OF_DAY=23,MINUTE=35,SECOND=35,MILLISECOND=908,ZONE_OFFSET=0,DST_OFFSET=0]
3) I then tried to remove the block "call clock format time" and in the google form I changed the field format = time
but then the google spreadsheet isn't populated with anything.
4)I tried using the segment block, but after a while I realised the block "format time" actually returns this format: "hh:mm:ss AM/PM"
so selecting the 5 characters is not good enough because it does not take into account of the am/pm element as well as the day of the month.
5) I found a temp solution by defining the desired delivery time as a new global variable, and extracting a string in the format hh:mm by joining the blocks ".hour instant" and ".minute instant".
However this is not a final solution because what i extracted is of course a string of text and when sorting, 01:10 will be always considered smaller than 23:50 for example, regardless of the date.
So is there a way of actually saving in the google spreadsheet not a string of text, but actually the date and time?
Problem B)
Secondly, I would like to filter/show only the rows of the google spreadsheet have a delivery time expired by no more than 1 hour (as well as orders with delivery time in the future e.g. in 2 hours from now()).
I tried using some Google Visualization API Query Language commands, altering the url of the google spreadsheet (like WHERE "now() - Delivery Time < 60 mins)" (cannot remember the exact code I wrote) but unsucessfully.
Would anyone know how to filter my results?
thanks in advance
alterettore
So there's a few things to note.
If you're using Taifun's example as you mention, you'll notice that when you submit data to Google Spreadsheets using a form, the first column is always a timestamp, even if you're not submitting a date or time. Trying to send the current date/time is redundant - go ahead and make use of what Google provided.
Google Spreadsheets (and Excel) store Date/Time as a number. If you want to store a date in GS, the best way to do so is not formatted text, but by sending a number. Use AppInventor to calculate the number you need. For example, today (April 27) in GS is 41756. Noon today would be 41756.5
To generate this number, start with AI's Millisecond function. NOTE: Both GS and AI use milliseconds, but they have different 0 points, so you have to manipulate the result a bit. The formula I've used in AI in the past is this:
GS Date/Time = (Clock1.GetMillis(Clock1.Now) / 86400000) + 25569
Hope this helps!

Showing only ONE week (Opening hours, each week the same)

I would like to know if it is possible to show only one week, to use this calendar for showing opening hours of a shop.
So :
- I don't want to show the day dates (only the day names) : OK
- I don't want to colorize the current day : OK
- I want the calendar display always the same week => I don't know how to do that...
Have you got any idea ? Is it possible to do that ?
Thanks a lot !
If you use the "goToDate" method:
gotoDate
Moves the calendar to an arbitrary
year/month/date.
.fullCalendar( 'gotoDate', year [,
month, [ date ]] )
IMPORTANT: month is 0-based, meaning
January=0, February=1, etc.
you could add your shop opening hours on the calendar for a given date, and then just show the date. However, you could also just add them for the current week being shown - this would then allow you to change times, for example, bank holidays etc. Have an array of special dates and print normally if not one of those dates...
Since version 1.3 and 1.4 fullcalendar is now able to show week view:
http://arshaw.com/fullcalendar/docs/views/
http://arshaw.com/fullcalendar/docs/views/Available_Views/
Example:
http://arshaw.com/fullcalendar/views/agendaWeek/

Setting report to current date

I have a report where it shows meetings and their requirements. However i just want the report to show ONLY today's stuff--not the entire week's worth.
I tried setting my group header (i'm grouping by day) to currentdate but yet it still shows me the entire week. I then have to go to the grouping tree and select today's date. Is there any way to run my report and have it ONLY show today's stuff and nothing else???
Any ideas?
Use the select expert to limit the results to today's date. printdate is a special Crystal Formula keyword.
{table.date_field} = printdate
Or, if you're working with a datetime db field you can strip the time with CDate
CDate({table.date_field}) = printdate
One way would be to change your query so that it's only getting one day's worth of data; that is, assuming your data contains a date field. To take it a step further, you could add date parameters to the query itself and leave the group headers as is. That way, you can have one day of data, or data from a specific date range.
If you have no influence (or desire) to change the way data comes into Crystal Reports, you could also add a formula via the Section Expert to suppress the group or detail section unless the date is the current date.

Resources