</permacrud>
</class>
+ <class id="ctz" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="config::timezone" oils_persist:tablename="config.timezone" reporter:label="Timezones" oils_persist:field_safe="true">
+ <fields oils_persist:primary="name">
+ <field reporter:label="Name" name="name" reporter:datatype="text"/>
+ </fields>
+ <links/>
+ <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+ <actions>
+ <retrieve/>
+ </actions>
+ </permacrud>
+ </class>
+
<class id="rlcd" controller="open-ils.cstore open-ils.pcrud open-ils.reporter-store" oils_obj:fieldmapper="reporter::last_copy_deleted" oils_persist:readonly="true" reporter:core="true" reporter:label="Last Copy Delete Time">
<oils_persist:source_definition>
# turn it into an interval that interval_to_seconds can parse
$duration =~ s/(\d{2}):(\d{2}):(\d{2})/$1 h $2 m $3 s/o;
- # for now, use the server timezone. TODO: use workstation org timezone
- my $due_date = DateTime->now(time_zone => 'local');
-
- # add the circ duration
- $due_date->add(seconds => OpenSRF::Utils->interval_to_seconds($duration));
+ # get time zone from org setting, failing that use local (server time zone)
+ my $tz = $U->ou_ancestor_setting_value($self->circ_lib, 'global.timezone') || 'local';
+
+ # set the due date to 'now' in that time zone
+ my $due_date = DateTime->now(time_zone => $tz);
+
+ # add the circ duration to get the actual due date
+ my $durationseconds = OpenSRF::Utils->interval_to_seconds($duration);
+ $due_date->add(seconds => OpenSRF::Utils->interval_to_seconds($durationseconds));
+
+ #push the due date to 23:59 (now in the local tz) for any loan that divides evenly into days
+ if($durationseconds % 86400 == 0){
+ $due_date = DateTime->new(
+ year => $due_date->year,
+ month => $due_date->month,
+ day => $due_date->day,
+ hour => 23,
+ minute => 59,
+ time_zone => $tz,
+ );
+ }
if($date_ceiling) {
my $cdate = DateTime::Format::ISO8601->new->parse_datetime(cleanse_ISO8601($date_ceiling));
CREATE UNIQUE INDEX unique_wwh ON config.usr_activity_type
(COALESCE(ewho,''), COALESCE (ewhat,''), COALESCE(ehow,''));
+-- you probably want to delete entries from this table
+CREATE TABLE config.timezone AS SELECT name FROM pg_timezone_names;
COMMIT;
CREATE TRIGGER mat_summary_change_tgr AFTER UPDATE ON action.circulation FOR EACH ROW EXECUTE PROCEDURE money.mat_summary_update ();
CREATE TRIGGER mat_summary_remove_tgr AFTER DELETE ON action.circulation FOR EACH ROW EXECUTE PROCEDURE money.mat_summary_delete ();
-CREATE OR REPLACE FUNCTION action.push_circ_due_time () RETURNS TRIGGER AS $$
-BEGIN
- IF (EXTRACT(EPOCH FROM NEW.duration)::INT % EXTRACT(EPOCH FROM '1 day'::INTERVAL)::INT) = 0 THEN
- NEW.due_date = (NEW.due_date::DATE + '1 day'::INTERVAL - '1 second'::INTERVAL)::TIMESTAMPTZ;
- END IF;
-
- RETURN NEW;
-END;
-$$ LANGUAGE PLPGSQL;
-
-CREATE TRIGGER push_due_date_tgr BEFORE INSERT OR UPDATE ON action.circulation FOR EACH ROW EXECUTE PROCEDURE action.push_circ_due_time();
-
CREATE OR REPLACE FUNCTION action.fill_circ_copy_location () RETURNS TRIGGER AS $$
BEGIN
SELECT INTO NEW.copy_location location FROM asset.copy WHERE id = NEW.target_copy;
'coust', 'description'),
'string', null)
+,( 'global.timezone','glob',
+ oils_i18n_gettext('global.timezone',
+ 'Timezone',
+ 'coust', 'label'),
+ oils_i18n_gettext('global.timezone',
+ 'Timezone to use for transaction processing',
+ 'coust', 'description'),
+ 'link', 'ctz')
+
,( 'gui.disable_local_save_columns', 'gui',
oils_i18n_gettext('gui.disable_local_save_columns',
'Disable the ability to save list column configurations locally.',
--- /dev/null
+
+--SELECT evergreen.upgrade_deps_block_check('0712', :eg_version);
+
+BEGIN;
+
+DO $$BEGIN RAISE WARNING 'We are populating config.timezone with all timezones from pg_timezone_names. It is recommended that you manually delete any timezones that you don\'t need.'; END;$$;
+CREATE TABLE config.timezone AS SELECT name FROM pg_timezone_names;
+
+--DROP TRIGGER push_due_date_tgr ON action.circulation;
+--DROP FUNCTION action.push_circ_due_time();
+
+INSERT into config.org_unit_setting_type
+ (name, grp, label, description, datatype)
+ VALUES ( 'global.timezone','glob',
+ oils_i18n_gettext('global.timezone',
+ 'Timezone',
+ 'coust', 'label'),
+ oils_i18n_gettext('global.timezone',
+ 'Timezone to use for transaction processing',
+ 'coust', 'description'),
+ 'link', 'ctz');
+
+COMMIT;