Time-Warp-0.54/0000755000175000017500000000000013356523563012616 5ustar manwarmanwarTime-Warp-0.54/.travis.yml0000644000175000017500000000017313337031027014714 0ustar manwarmanwarbranches: except: - gh-pages language: perl perl: - "5.20" - "5.18" - "5.16" - "5.14" - "5.12" - "5.10" Time-Warp-0.54/t/0000755000175000017500000000000013356523562013060 5ustar manwarmanwarTime-Warp-0.54/t/when.t0000644000175000017500000000105113337031027014170 0ustar manwarmanwaruse 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); Time-Warp-0.54/Makefile.PL0000644000175000017500000000165413337031657014573 0ustar manwarmanwaruse 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/manwar/Time-Warp.git', web => 'http://github.com/manwar/Time-Warp', license => 'http://dev.perl.org/licenses/', }, bugtracker => { web => 'http://github.com/manwar/Time-Warp', }, }, }; } WriteMakefile(%conf); Time-Warp-0.54/Warp.xs0000644000175000017500000000532113337031027014070 0ustar manwarmanwar#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.54/README0000644000175000017500000000035113337031027013461 0ustar manwarmanwarTime::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.54/META.json0000664000175000017500000000240713356523563014244 0ustar manwarmanwar{ "abstract" : "control over the flow of time", "author" : [ "Joshua Nathaniel Pritikin " ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 7.24, CPAN::Meta::Converter version 2.150005", "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/manwar/Time-Warp" }, "repository" : { "type" : "git", "url" : "http://github.com/manwar/Time-Warp.git", "web" : "http://github.com/manwar/Time-Warp", "x_license" : "http://dev.perl.org/licenses/" } }, "version" : "0.54", "x_serialization_backend" : "JSON::PP version 2.27400" } Time-Warp-0.54/Warp.pm0000644000175000017500000000412213356523315014057 0ustar manwarmanwaruse 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.54'; __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 permissible 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.54/MANIFEST0000644000175000017500000000040613356523563013747 0ustar manwarmanwar.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.54/META.yml0000664000175000017500000000125513356523562014073 0ustar manwarmanwar--- 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.24, CPAN::Meta::Converter version 2.150005' 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/manwar/Time-Warp repository: http://github.com/manwar/Time-Warp.git version: '0.54' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' Time-Warp-0.54/Changes0000644000175000017500000000165713356523533014117 0ustar manwarmanwarRevision history for Time::Warp 0.54 2018.10.08 MANWAR - Merged PR #4 (Pod Spelling), thanks @gregoa. 0.53 2018.08.22 - New maintainer (MANWAR) - Updated GitHub repo details. - Tidied up Changes. 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