Commit graph

223 commits

Author SHA1 Message Date
Felix Krause
170745eb39 Removed tzname because it's broken
* No mapping between TimeInfo.tzname and TimeInfo.timezone
 * tzname of time.h is not well-defined, may have almost arbitrary
   length, and localization may differ
 * Code used hardcoded "UTC" string
2016-11-01 20:26:50 +01:00
Felix Krause
c1f0b7643c Fixed timezone offset parsing 2016-11-01 19:33:43 +01:00
Felix Krause
96234f36ca Made times.nim compile again to JS 2016-11-01 18:42:22 +01:00
Felix Krause
2ec6fe56ad Fixed timezone handling
* mktime always interprets its input as local time even on systems where
   gmtoff is present, so using it is utterly useless for anything but getting
   the local timezone. Removed all other usage of gmtoff to avoid confusion.
 * Properly handle timezone offset in toTime()
 * Properly handle timezone offset in `$` because asctime also interprets its
   input as local time
 * Also tried to fix the JavaScript implementation
2016-11-01 17:22:50 +01:00
Araq
47304372ca change TimeImpl for MingW 2016-11-01 14:11:46 +01:00
Jonathan Bernard
b7232bd425 Fix #4922, bug in times.parse, mishandling DST. 2016-10-21 17:06:36 -05:00
Jonathan Bernard
68d3486f5a Bugfix for times.initInterval (issue #4889)
`initInterval` had logic to calculate and carry overflowed fields (65 seconds
turns into 5 seconds and carries 1 minute). However, we were not including that
carried value when we recalculate the carry over for the next period of time.So
if you had, for example, 3600 seconds, we carried 60 minutes into the minutes
calculation, but when we calculated how much we should carry into the hours
value we only considered what the user originally supplied for the minutes
field, and forgot to include those 60 carried minute.

So, for example, with the previous implementation this was true:

`seconds(60 * 60 * 24) == seconds(0)`

Or, as failing tests:

```nimrod
import times

assert seconds(60 * 60 * 24) != seconds(0)
assert seconds(60 * 60 * 24) == days(1)
```
2016-10-12 15:44:21 -05:00
Felix Krause
68680a9880 Calculate correct yearday in times.parse 2016-08-19 12:34:10 +02:00
Andreas Rumpf
60b187513e stdlib and compiler don't use .immediate anymore 2016-07-29 23:51:01 +02:00
Andreas Rumpf
0834cd63d9 prepare Nim codebase for upcoming parser changes 2016-07-15 12:56:03 +02:00
Dominik Picheta
8182414a6f Fix times.+ and - for TimeInfo and TimeInterval. 2016-06-18 16:11:57 +01:00
Yuriy Glukhov
7389662809 Time has now reference semantics on js 2016-06-01 18:46:58 +03:00
cheatfate
2264bd6097 Adding OpenBSD to defines 2016-05-30 14:39:29 +03:00
cheatfate
b7f2058833 Resolve #3059
Make getTimezone() to work properly on FreeBSD and NetBSD.
2016-05-30 13:18:31 +03:00
Dominik Picheta
9b6fda144a Some documentation fixes in times module. 2016-04-06 10:45:39 +01:00
coffeepots
d9ed61fa62 Deprecate timeToTimeInfo, add str->time procs
* depreciate timeToTimeInfo, add str->time procs

initTime allows creating times from strings. initTimeFromStr offers a default format string compatible with $Time.
timeToTimeInterval changed to work properly.

* Spell {.deprecated.} correctly

* deprecated timeToTimeInfo, removed initTime procs

Is it even worth depreciating timeToTimeInfo rather than just removing it, considering it's just wrong and we have getLocalTime and getGMTime that actually work? Also, if I'm renaming timeToTimeInfo -> toTimeInfo etc, isn't the deprecated tag kind of redundant?

* Updated names for toTime and toTimeInterval procs

* Added type to toTime template

This should allow compilation of os.nim now that toTime is defined in times.nim.

* Updated toTime template to use {.gensym.}

Local templates default to 'bind' semantics, not 'gensym'. This was causing a failure to 'see' the local toTime template.
2016-04-06 10:36:17 +01:00
Federico Ceratto
d9cb85c2d8 Spellcheck 2016-02-29 11:25:51 +00:00
Anatoly Galiulin
5cfb653094 Fixed issue 3905 with getTimezone in js 2016-02-26 16:17:38 +06:00
Dominik Picheta
fffdae32c7 Fixed TimeInterval bug. 2016-01-08 11:54:34 +00:00
Dominik Picheta
09b159b816 Fixed ttime test. Improved docs in times module. 2016-01-08 11:46:11 +00:00
JamesP
8af8f7673b add timeinterval helping functions as per issue #3609
add tests to ttime.nim for timeinterval add/subtract functionality

Changed assert to doAssert in ttime.nim
Added extra tests to ttime.nim
Removal of singular help procs for working with TimeIntervals
Added TimeIin proc toSeconds(a: TimeInfo, interval: TimeInterval) where subtracting a year gave wrong results
Add overflow of units on initInterval eg, 65 seconds is 5 seconds and 1 minute
2015-12-08 10:16:42 +10:00
JamesP
def25504e8 Add comment at end of file on where to find further tests 2015-12-01 23:05:37 +10:00
JamesP
f62e8558c8 Removal of tests from times module, that have been moved to ttime.nim test file 2015-12-01 18:08:52 +10:00
Araq
e94a6ec1f9 added an assertion 2015-10-27 08:37:43 +01:00
JamesP
2d1f26302c Example: add extra getGmTime interval addition example 2015-09-10 19:29:26 +10:00
JamesP
f5d55ad012 tests added: toSeconds with local/GM timezones, interval add/sub
with local/GM timezones
2015-09-10 19:21:27 +10:00
JamesP
c122d71e66 bug fix: + and - handle GM and Local time correctly
eg,  getGmTime(getTime()) + initInterval(hours=1) gave incorrect results
2015-09-10 17:38:00 +10:00
JamesP
612cd2161a add examples block to top of times module 2015-09-10 17:29:52 +10:00
Adam Strzelecki
ef5f0b1ac9 times: Export & document countLeapYears/Years/Days
Previously countYears & countDays procs were not public, but there were unused,
causing unnecessary warnings generated by standard library.

Since these procs seems to be useful it is better to just export them than
remove them completely. Also turning inline comments into proper documentation.
2015-09-03 10:39:14 +02:00
Yuriy Glukhov
2f8d4c17d8 Fixed compilation of times module with JS. 2015-08-14 12:57:07 +03:00
Yuriy Glukhov
ad98877584 Fixed fromSeconds function JS variant 2015-08-12 18:31:38 +03:00
Dominik Picheta
34ca9dd586 Merge pull request #3114 from coffeepots/patch-1
Procs to decode Time to TimeInfo & TimeInterval
2015-08-08 20:56:14 +01:00
Dominik Picheta
85699b744d Merge pull request #3161 from barcharcraz/fix_times_on_vcc2015
import the correct symbols on windows
2015-08-03 17:08:14 +01:00
Charlie Barto
4d6bcbc2f4 make this change VCC specific 2015-08-02 18:55:35 -04:00
Charlie Barto
ad896f03e8 import the correct symbols on windows 2015-07-31 15:08:53 -04:00
coffeepots
f9d909bb94 Removed unused leapYearsSinceEpoch 2015-07-31 10:20:21 +01:00
coffeepots
5e0b8d5ef6 Implemented changes suggested by dom96
* Removed extraneous exports (and converted const array to separate consts)
* Renamed dayOfWeek, dayOfWeekJulian to getDayOfWeek and getDayOfWeekJulian
* Renamed decodeTime procs to timeToTimeInfo and timeToTimeInterval
* Added some basic descriptions to docs
2015-07-31 09:44:37 +01:00
Dominik Picheta
a88131ed4a Improved errors in times.parse. 2015-07-24 22:46:24 +01:00
Magnus Holm
fdf454e3ae Fix times' parse with literal strings 2015-07-24 18:08:05 +02:00
coffeepots
a2f0fe03b6 Fixed dayOfWeekJulian, exported SecondScale 2015-07-16 10:20:34 +01:00
coffeepots
f09916d720 Procs to decode Time to TimeInfo & TimeInterval
Fills in the missing functionality of decoding Time to TimeInfo and TimeInterval, whilst also adding some procs to work with leap years and to get the day of the week based on a date.
2015-07-14 11:58:26 +01:00
apense
71743b5af3 Added getDaysInYear proc 2015-07-06 01:03:34 -04:00
Araq
ccb9ae2d52 stdlib: don't use deprecated symbols 2015-06-04 13:18:42 +02:00
pdw
cb6f867495 Fixed 'milliseconds' spelling in code and docs 2015-05-15 20:15:12 -05:00
def
60862c22f5 Year shouldn't be arbitrarily limited to -10_000 .. 10_000. Instead it's
an int now.
2015-04-29 21:34:03 +02:00
Araq
6725aa3634 fixes #2517 2015-04-25 23:16:59 +02:00
Oleh Prypin
22db40e5e4 Turn some test outputs into actual tests 2015-04-21 15:59:32 +03:00
Oleh Prypin
32109a7867 Don't run non-test code when defined(testing) 2015-04-21 14:37:29 +03:00
yglukhov
9e2d6d072c Implemented epochTime function for JS target. 2015-03-31 00:23:43 +03:00
def
b0c64bf848 Use <time.h> instead of <sys/time.h> for tzset and time_t
This fixes compilation on Linux.
2015-03-23 11:03:44 +01:00