Giter VIP home page Giter VIP logo

datetime's Introduction

Date and Time 3

Date and Time Field

Date and Time provides advanced date and time management for Symphony. It offers an easy interface providing a calendar widget that helps creating multiple dates and date ranges. The field respects the system settings and displays date and time accordingly. Nevertheless, it is capable to read and understand relative date formats.

Installation

Information about installing and updating extensions can be found in the Symphony documentation at http://www.getsymphony.com/learn/.

Updating

To update Date and Time to a newer version perform the following steps:

  • Make sure that you have a working backup of your Symphony install.
  • Update the Date and Time folder by either updating the repository and submodule or by replacing the files manually.
  • Log into the backend and enable the Date and Time extension to run the update script.

All interface related components of Date and Time are JavaScript based. Please make sure to clear your browser cache to avoid interface issues. If another extension or the Symphony core throws a JavaScript error, Date and Time will stop working.

Field Settings

Date and Time offers the following field settings:

  • allow creation of new items: this will add a Create New button to the interface
  • allow sorting of items: this will enable item dragging and reordering
  • allow time editing: this will display date and time in the interface
  • allow date ranges: this will enable range editing
  • pre-populate this field with today's date: this will automatically add the current date to new entries

Field Behaviour

General

  • Clicking the date input will open the calendar.
  • Clicking on a day in the calendar will either select or update the date.
  • Clicking outside the field will close all calendars.
  • If enabled, dragging dates will sort the date listing.

Date ranges

  • Clicking either the start or end date input will open the calendar showing the selected date.
  • Clicking on a date in the calendar will either select or update the date.
  • Hitting the tab key in the start input will create a range an jump to the end date.
  • Clicking on a day in the calendar will either select or update a single date.
  • Clicking on a day in the calendar while holding down shift will create a day range.

Times

  • Clicking on a time will set start and end date to the same time.
  • Clicking on a time while holding down shift will create a time range.

Data Source Filtering

  • prefixing a filter with start: will only check start dates,
  • prefixing a filter with end: will only check end dates,
  • prefixing a filter with strict: will check, if start and end date are in the given filter range,
  • filters without prefixes will check, if start or end date are in the given filter range.
  • prefixing a filter with extended: will work like the unprefixed filter but will treat single dates as an "open range", starting with the given date but never ending.

Filters separated by comma will find all dates that match one of the given dates or ranges.
Filters separated by + will only find dates that match all of the given dates or ranges.

This extensions accepts all relative dates known to PHP's DateTime class for filtering. It also allows the creation of filter ranges with to or earlier than and later than.

Example Data Source Output

<date-and-time>
    <date timeline="1" type="range">
        <start iso="2011-12-06T10:00:00+01:00" time="10:00" weekday="2" offset="+0100">2011-12-06</start>
        <end iso="2011-12-24T18:00:00+01:00" time="18:00" weekday="6" offset="+0100">2011-12-24</end>
    </date>
    <date timeline="2" type="exact">
        <start iso="2011-12-25T09:00:00+01:00" time="09:00" weekday="7" offset="+0100">2011-12-25</start>
    </date>
</date-and-time>

Acknowledgement

This extension is not a work of a single person, a lot of people tested it and contributed to it. The initial layout of the date widget was inspired by Scott Hughes' calendar mock-up for Symphony 2.0 and Rowan Lewis' calendar overlay.

datetime's People

Contributors

a-ntoine avatar alexbirukov avatar beaubbe avatar brendo avatar creativedutchmen avatar domsammut avatar jonmifsud avatar klaftertief avatar nilshoerrmann avatar nitriques avatar pascalpiche avatar peterfleck avatar simoneeconomo avatar wdebusschere avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

datetime's Issues

DateJS Core

In a project I'm working with at the moment the I have to use both this DateTime extension and the Calendar Overlay extension. As mentioned before on the forums, there's a conflict between the two.

I traced it down and it boils down to a conflict with the Date JS libraries. The Calendar Overlay is applied last in the <head> and version is 1 year newer * @date: 2008-05-13 whereas the one included in the datetime.js is * Build Date: 13-Nov-2007.

The differences in here cause an issue on line 63 because the day.text() returns say '5' in the old version, but will return a full '5/11/09' because of some changes to the DateJS.

My hackish workaround is:

            if(day.text().indexOf("/") == -1) {
                var date = Date.parse(month + ' ' + year + ' ' + day.text());
            } else {
                var date = Date.parse(day.text());
            }

The calendar looks broken (full dates instead of day's) but the functionality works and that's the main thing!

I guess the option would be to update this extension to use the new DateJS library, or namespace this version of the library so that it would use it and not any other ones.

Grouping

It appears that grouping by the datetime results in the datasource not displaying anything using 1.3dev.

The three entries were using only single dates, 17th, 28th and 30th of November respectively

Localized month

My system language setting is German, however, the date is still displayed as "04. May 2011, 12:50" in my date/time field. The calendar shows the right month name ("Mai"), though.

Multiple Dates with no End

Hi Nils,

Been testing 1.3dev on a new site build to help debug. I've found a bug at the moment that occurs when you add more then one date to an entry with no end. On the section's frontend they display a bit quirky because they have no end.

from 27 November 2009 11:52 am to 30 November -0001 12:00 am,
from 04 December 2009 11:56 am to 30 November -0001 12:00 am,
from 11 December 2009 11:56 am to 30 November -0001 12:00 am

Also, do you think this output should be capped so that the rows don't expand to a grossly long length? Perhaps something more like 27 November 2009, 04 December 2009 and 1 other date. A nice way to tweak it would be to show the next date(s) instead of just the first one's. So if it was the 30th November today, the output would be 04 December 2009 and 11 December 2009.

With the capping idea, maybe this could be applied to the entry page too so that the field area doesn't expand past 'x' height. It's more visual than anything, but for entries where there could be a few dates (ie. I'm expecting some things might have a weekly date).

Thoughts?

Timeline / Timer

The far left edge of the timeline should start at 0:00 (right now, the timer shows 23:35, but when selecting the time, the marker is set at the right spot).

The far right edge of the timeline should end at 23:55 (right now it goes further, although it seems like I can only select 23:55 as the latest time).

The timer disappears under the far right edge -- instead, it should "stick" to the edge or flip to the left of my marker.

Too Much Recursion Error

Hi Nils, I'm getting the following error.

Error: too much recursion
Source File: http://localhost:8888/extensions/datetime/assets/international/datejs.en.js
Line: 61

wrong year when entering a time range

Everything is fine when entering the first date and time (let's say December 14, 2009 / 18:30) but when I use the "end"-slider to define a time (e. g. 21:30) the dates' years are automatically changed (December 14, 2005 / 21:30 to December 14, 2006 / 18:30). I can change the year back to 2009 in the input field though.

Prepopulate Error

If you don't check Pre-populate this field with today's date you can't select a date via the entry frontend as it interprets the empty field as a formatting error and won't open the calendar.

Calendar not displaying.

I had some trouble with this extension at first but then I figured out how to reproduce this odd behavior. When I create a new entry of a section with the datetime field the calendar does not pop underneath. Date and time can be entered as expected. Changes saved. Only then, after changes are saved, will the calendar pop out and become usable.

I'm using 2.0.7 and 1.3. Let me know if you'd like more information.

Example Event Markup

I just spent some time baffled as to why my event wasn't populated the datetime field correctly. Turns out:

<label>Date
   <input name="fields[date]" type="text" />
</label>

Doesn't work, and instead it should be

<label>Date
    <input name="fields[date][start][]" type="text" />
</label>

Roadmap for version 1.4

General

  • Create and implement Stage for interface interaction.
  • Generate language strings for the extension on the fly using Symphony's core translation function (do not rely on dateJS' internationalisation files)

Calendar

  • Make the calendar a separate jQuery plugin.
  • Do only take the needed parts of dateJS. It's great for some things but it causes trouble as well.
  • When scrolling through the month or year select box, add newer or older years/months on the fly.

New Features

  • Repeating dates.
  • Time filtering for data sources.
  • Calendar overlay option for Symphony date fields.
  • Allow single item calendars to be always open.

display:inline

Using a range applies display:inline to the

This breaks the display of the field and looks ugly. Removing the inline style fixes the display issue.

Visualisation conflict

When you clicked the calendar for the first time, the blur event overrides the visualisation of the newly selected date.

"delete" doesn't completely delete the selection

When one date is set, the "delete" button resets the input field to my current date and time but the green date selection in the calendar isn't deleted.

When a range is set, the "delete" button resets both input fields (start and end) to my current date and time but the green range selection in the calendar isn't deleted.

New admin instance check causing issue on 2.1.1

The new administration instance check:

File: fields/field.datetime.php
Line: 173

if (Administration instanceof Symphony) {

Causes the extension not to work when editing a section under Symphony 2.1.1 (at least on my installation).

Commenting out the check causes everything to work as expected.

Fatal Error When Creating Components > Event based on Section with Date/Time field applied

@nils thanks for the great extension. Its been quite useful so far.

I found a serious issue – at least for me – yesterday. When I tried to create an Event – as in Components > Event – using a section that includes an instance of the Date/Time field, I get a big nasty FATAL ERROR message. Contents below:

<b>Fatal error</b>:  Uncaught exception 'Exception' with message 'Child is not of type XMLElement' in …/symphony/lib/toolkit/class.xmlelement.php:166
Stack trace:
#0 …/symphony/content/content.blueprintsevents.php(310): XMLElement-&gt;generate(true)
#1 …/symphony/content/content.blueprintsevents.php(164): contentBlueprintsEvents-&gt;__formAction()
#2 …/symphony/lib/toolkit/class.administrationpage.php(111): contentBlueprintsEvents-&gt;__actionEdit()
#3 …/symphony/lib/toolkit/class.administrationpage.php(92): AdministrationPage-&gt;__switchboard('action')
#4 …/symphony/lib/toolkit/class.administrationpage.php(62): AdministrationPage-&gt;action()
#5 …/symphony/lib/core/class.administration.php(84): AdministrationPage in <b>…/symphony/lib/toolkit/class.xmlelement.php</b> on line <b>166</b><br />

I spent some time narrowing this down to a point where I am fairly certain it has at least something to do with this extension. Let me know if there is anything else you need to help fix this issue.

Implement prepareImportValue

The XMLImporter looks for the prepareImportValue function on fields before attempting to import the values into a section.

At a very basic level, the following allows dates to be imported into the field, but it could be expanded so that it will recognise ranges and add them to the start/end keys as appropriate

    function prepareImportValue($data) {
        return array(
            'start' => $data
        );
    }

'Symphony Fatal Database Error' when date not set

This extension currently causes a 'Symphony Fatal Database Error' to be thrown when the date is not set.

This can be fixed so that the extension assumes a null date by adding the following:

File: fields/field.datetime.php
Line: 272
Remove the start check and modify to:

$result['entry_id'][] = $entry_id;
$result['start'][] = empty($data['start'][$i]) ? '0000-00-00 00:00:00' : date('c', strtotime(str_replace($this->locale, self::$english, $data['start'][$i])));
$result['end'][] = empty($data['end'][$i]) ? '0000-00-00 00:00:00' : date('c', strtotime(str_replace($this->locale, self::$english, $data['end'][$i])));

Modify the datasource output to ignore the null dates:

File: fields/field.datetime.php
Line: 644
Add in after empty date check:

if($data['start'][$id] == "0000-00-00 00:00:00") continue;

Then modify the JavaScript to display nothing when the null date is encountered:

File: assets/datetime.js
Line: 26
Add in:

if(this.value == '0000-00-00 00:00:00') {
    $(this).val('');
    return;
}

[Experimental Branch] Error when updating

MySQL Error (1064): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''' at line 3 in query "ALTER TABLEsym_entries_data_85MODIFYstartvarchar(255) NOT NULL, MODIFYendvarchar(255)'" when updating from 1.5

directly open calendar for new dates

It would be great if adding a new date would automatically open the calendar for this date. Right now, it is a bit confusing as you click new date but the shown calendar actually belongs to the previous date. Maybe automatically setting the cursor to the new date would do the trick? I have no idea really :)

Time saved even when not specified

If you set this extension up to only have the date but not the time, it still will save and display the time as well as the date. The time appears to be whatever time the entry was created at.

Expected behavior would be for it to only show the date if that's what was entered.

Fix slider length for updated single dates

If a the timer was set to a range and a new single date is selected in the calendar, the timer range will not be cleared correctly. If the the range uses multiple days the second timeline is removed though.

Incorrent calendar days

If you look at April, it shows it has 30 days but if you are in May, it says April has 31 days and is pushing the schedule ahead by one day. So 1st of May is reading as Monday instead of Sunday.

You can see the screenshots here: http://img860.imageshack.us/g/datetimeapril.png/

This is consistent in both version 2.0RC1 and version 2.0dev

ISO Output Broken in 1.3dev

Me again. 1.3dev results in an incorrect (well not the same as 1.2) @iso value returning.

1.3 dev
2009-11-27
1.2
2009-11-22

(yes they are two different dates, that's not a bug)

Multiple dates not returned properly

Come across this bug today. If you have a field with two or more dates and neither of those dates are a range (i.e., no end date) then class.entrymanager.php kills the data when it's being returned to the Publish screen.

Seems to be caused by this check on line 366 of class.entrymanager.php:

else if (!isset($raw[$entry_id]['fields'][$field_id][$key])) {
    $raw[$entry_id]['fields'][$field_id] = array($r[$key]);
}

Because the [end] array in the field data is empty that check is destroying all the data as it's returned. I can't seem to think of a good solution that doesn't involved modifying the core. Thoughts?

2.0RC1 JavaScript Error

Getting the following error when I add this to one of my sections in Symphony 2.2.1:

In timer.publish.js (line 269):

range.position() is null

But it's only happening in one section. In another section it's fine. Investigating...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.