Time-Warp-0.52/000755 000765 000024 00000000000 12513647404 013510 5ustar00gaborstaff000000 000000 Time-Warp-0.52/.travis.yml000644 000765 000024 00000000173 12420166070 015612 0ustar00gaborstaff000000 000000 branches: except: - gh-pages language: perl perl: - "5.20" - "5.18" - "5.16" - "5.14" - "5.12" - "5.10" Time-Warp-0.52/Changes000644 000765 000024 00000001260 12513647054 015003 0ustar00gaborstaff000000 000000 0.52 2015.04.16 The type of the Time::NVtime pointer is NV ()() not double ()(), as can be seen from looking at the Time::HiRes source. On Linux x86_64 on a uselongdouble build when you replace the Time::NVtime entry with a double (*)() pointer calls to that function end up leaving an entry on the FPU stack, eventually causing the failure seen at https://rt.perl.org/Ticket/Display.html?id=123879 This minimal commit fixes that issue and allows DBIX::Class::TimeStamp to pass its tests. (Tony Cook) 0.51 2014.10.17 New maintainer (SZABGAB) Use Test::More instead of Test Include META.yml RT #77752 POD encoding is now utf8 RT #93259 Time-Warp-0.52/Makefile.PL000644 000765 000024 00000001407 12513647160 015463 0ustar00gaborstaff000000 000000 use ExtUtils::MakeMaker; require 5.006; my %conf = ( NAME => 'Time::Warp', AUTHOR => 'Joshua Nathaniel Pritikin ', VERSION_FROM => 'Warp.pm', ABSTRACT_FROM => 'Warp.pm', LICENSE => 'perl', OBJECT => 'Warp.o', OPTIMIZE => '-g', PREREQ_PM => { 'Test::More' => '1.00', }, ); if (eval { ExtUtils::MakeMaker->VERSION(6.46) }) { $conf{META_MERGE} = { 'meta-spec' => { version => 2 }, resources => { repository => { type => 'git', url => 'http://github.com/szabgab/Time-Warp.git', web => 'http://github.com/szabgab/Time-Warp', license => 'http://dev.perl.org/licenses/', }, bugtracker => { web => 'http://github.com/szabgab/Time-Warp', }, }, }; } WriteMakefile(%conf); Time-Warp-0.52/MANIFEST000644 000765 000024 00000000406 12513647404 014641 0ustar00gaborstaff000000 000000 .travis.yml Changes Makefile.PL MANIFEST This list of files README t/when.t Warp.pm Warp.xs META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) Time-Warp-0.52/META.json000644 000765 000024 00000002317 12513647404 015134 0ustar00gaborstaff000000 000000 { "abstract" : "control over the flow of time", "author" : [ "Joshua Nathaniel Pritikin " ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 7.04, CPAN::Meta::Converter version 2.150001", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Time-Warp", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "runtime" : { "requires" : { "Test::More" : "1.00" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "http://github.com/szabgab/Time-Warp" }, "repository" : { "type" : "git", "url" : "http://github.com/szabgab/Time-Warp.git", "web" : "http://github.com/szabgab/Time-Warp", "x_license" : "http://dev.perl.org/licenses/" } }, "version" : "0.52" } Time-Warp-0.52/META.yml000644 000765 000024 00000001165 12513647403 014763 0ustar00gaborstaff000000 000000 --- abstract: 'control over the flow of time' author: - 'Joshua Nathaniel Pritikin ' build_requires: ExtUtils::MakeMaker: '0' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 7.04, CPAN::Meta::Converter version 2.150001' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Time-Warp no_index: directory: - t - inc requires: Test::More: '1.00' resources: bugtracker: http://github.com/szabgab/Time-Warp repository: http://github.com/szabgab/Time-Warp.git version: '0.52' Time-Warp-0.52/README000644 000765 000024 00000000351 07142067626 014373 0ustar00gaborstaff000000 000000 Time::Warp - offers developers control over the measurement of time SYNOPSIS use Time::Warp qw(scale to time); to(CORE::time + 5); # 5 seconds ahead scale(2); # double speed of time AVAILABLE FROM CPAN! Time-Warp-0.52/t/000755 000765 000024 00000000000 12513647403 013752 5ustar00gaborstaff000000 000000 Time-Warp-0.52/Warp.pm000644 000765 000024 00000004122 12513647250 014755 0ustar00gaborstaff000000 000000 use strict; package Time::Warp; use vars qw(@ISA @EXPORT_OK $VERSION); require Exporter; require DynaLoader; @ISA = qw(DynaLoader Exporter); @EXPORT_OK = qw(reset to scale time); $VERSION = '0.52'; __PACKAGE__->bootstrap($VERSION); install_time_api(); 1; __END__ =encoding utf8 =head1 NAME Time::Warp - control over the flow of time =head1 SYNOPSIS use Time::Warp qw(scale to time); to(time + 5); # 5 seconds ahead scale(2); # make time flow twice normal =head1 DESCRIPTION Our external experience unfolds in 3 1/2 dimensions (time has a dimensionality of 1/2). The Time::Warp module offers developers control over the measurement of time. =head1 API =over 4 =item * to($desired_time) The theory of relativity asserts that all physical laws are enforced relative to the observer. Since the starting point of time is arbitrary, it is permissable to change it. This has the effect of making it appear as if time is moving forwards or backward instanteously. For example, on some types of operating systems time starts at Wed Dec 31 19:00:00 1969 (this will likely change as we approach 2030 and with the acceptance of 64-bit CPUs). to(time + 60*60); # 1 hour ahead =item * scale($factor) Changes the speed at which time is progressing. scale(scale * 2); # double the speed of time Note that it is not possible to stop time or cause it to reverse since this is forbidden by the second law of thermodynamics. =back =head1 ALSO SEE L and L. =head1 SUPPORT Please direct your insights or complaints to perl-loop@perl.org. =head1 DISCLAIMER THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THIS IS NOT A TIME MACHINE. THIS MODULE CANNOT BE USED TO VIOLATE THE SECOND LAW OF THERMODYNAMICS. =head1 COPYRIGHT Copyright © 1999, 2000 Joshua Nathaniel Pritikin. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut Time-Warp-0.52/Warp.xs000644 000765 000024 00000005321 12513646603 014776 0ustar00gaborstaff000000 000000 #ifdef __cplusplus extern "C" { #endif #define MIN_PERL_DEFINE 1 #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #ifdef __cplusplus } #endif /* Is time() portable everywhere? Hope so! XXX */ static NV fallback_NVtime() { return time(0); } static void fallback_U2time(U32 *ret) { ret[0]=time(0); ret[1]=0; } /*-----------------*/ static int Installed=0; static NV (*realNVtime)(); static void (*realU2time)(U32 *); static double Lost; /** time relative to now */ static double Zero; /** apply Scale from when? */ static double Scale; /** speed of time (.5 == half speed) */ static void reset_warp() { Lost=0; Zero=(*realNVtime)(); Scale=1; } /*-----------------*/ static NV warped_NVtime() { double now = (*realNVtime)() - Lost; double delta = now - Zero; delta *= Scale; return Zero + delta; } static void warped_U2time(U32 *ret) { /* performance doesn't matter enough for a native non-float implementation */ double now = warped_NVtime(); U32 unow = now; ret[0] = unow; ret[1] = (now - unow) * 1000000; } MODULE = Time::Warp PACKAGE = Time::Warp PROTOTYPES: ENABLE void install_time_api() CODE: { SV **svp; if (Installed) { warn("Time::Warp::install_time_api() called more than once"); return; } Installed=1; svp = hv_fetch(PL_modglobal, "Time::NVtime", 12, 0); if (!svp) { warn("Time::Warp: Time::HiRes is not loaded --\n\tat best 1s time accuracy is available"); hv_store(PL_modglobal, "Time::NVtime", 12, newSViv((IV) fallback_NVtime), 0); hv_store(PL_modglobal, "Time::U2time", 12, newSViv((IV) fallback_U2time), 0); } svp = hv_fetch(PL_modglobal, "Time::NVtime", 12, 0); if (!SvIOK(*svp)) croak("Time::NVtime isn't a function pointer"); realNVtime = (NV(*)()) SvIV(*svp); svp = hv_fetch(PL_modglobal, "Time::U2time", 12, 0); if (!SvIOK(*svp)) croak("Time::U2time isn't a function pointer"); realU2time = (void(*)(U32*)) SvIV(*svp); hv_store(PL_modglobal, "Time::NVtime", 12, newSViv((IV) warped_NVtime), 0); hv_store(PL_modglobal, "Time::U2time", 12, newSViv((IV) warped_U2time), 0); reset_warp(); } void reset() CODE: reset_warp(); void to(when) double when CODE: { Lost += (warped_NVtime() - when) / Scale; } void scale(...) PPCODE: { if (items == 0) { XPUSHs(sv_2mortal(newSVnv(Scale))); } else { Zero = warped_NVtime(); Lost = 0; Scale = SvNV(ST(0)); if (Scale < 0) { warn("Sorry, Time::Warp cannot go backwards"); Scale = 1; } else if (Scale < .001) { warn("Sorry, Time::Warp cannot stop time"); Scale = .001; } } } void time() PPCODE: { XPUSHs(sv_2mortal(newSVnv(warped_NVtime()))); } Time-Warp-0.52/t/when.t000644 000765 000024 00000001051 12420165227 015071 0ustar00gaborstaff000000 000000 use strict; use warnings; # These tests may occationally fail due to small timing differences. use Test::More tests => 8; { local $SIG{__WARN__} = sub { if ($_[0] =~ /Time::HiRes/) { ok 1; } else { warn $_[0]; } }; require Time::Warp; } Time::Warp->import(qw(time to scale)); ok 1; is scale(), 1; scale(2); is &scale, 2; my $now = &time; sleep 2; is(&time - $now, 4); to(CORE::time); is(&time - CORE::time, 0); scale(scale() * 2); is(&time - CORE::time, 0); Time::Warp::reset(); to(&time + 5); is(&time - CORE::time, 5);