posix_time¶
- class contrib.misc.posix_time.PosixTests[source]¶
Bases:
BahaiCalendarPOSIX converter: https://www.unixtimestamp.com/Julian Period Converter: https://aa.usno.navy.mil/data/JulianDateThe Python datetime package seems to always give local time from timestamps not UTC time. For Example:
In [18]: dtime.datetime.fromtimestamp(18000) This -5 hours from UTC time.Out[19]: datetime.datetime(1970, 1, 1, 0, 0)- EPOCH = badidatetime.datetime(126, 16, 2, None, None, 7, 59, 32, 488800, tzinfo=badidatetime.timezone.utc)¶
- GMT_COORD = (51.477928, -0.001545, 0)¶
- _MONTHS = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 0, 19)¶
- _get_badi_hms(b_date, coords: tuple) tuple[source]¶
Find the correct Badí’ hour, minute, and second after sunset equal to UTC midnight based on the coordinents.
Time Zone
Badí’ Date
Sunset before epoch in hrs
Approx JD
GMT 0.0 time
0126-16-02T08:00:00+00:00
16:00
0.33333333
EST -5.0 time
0126-16-02T06:48:00-05:00
17:11
0.283310188
Tehran 3.5 time
0126-16-02T06:59:00+03:30
17:01
0.29097220
Beijing 8.0 time
0126-16-02T07:01:00+08:00
16:59
0.292361104
Use the last value returned, the first two are only for testing.
- _mktime(dt: datetime, coords: tuple) float[source]¶
This is the inverse function of localtime(). Its argument is the struct_time or full 9-tuple (since the dst flag is needed; use -1 as the dst flag if it is unknown) which expresses the time in local time, not UTC. It returns a floating-point number, for compatibility with time(). If the input value cannot be represented as a valid time, either OverflowError or ValueError will be raised (which depends on whether the invalid value is caught by Python or the underlying C libraries). https://en.wikipedia.org/wiki/Time_zone
Derived Badí’ time for the epoch 1970-01-01¶
Time Zone
Badí’ Date
GMT 0.0 time
126-16-02T08:00:30.6684+00:00
EST -5.0 time
0126-16-02T01:48:23.8716-05:00
Tehran 3.5 time
0126-16-01T:10:28:46.1388+03:30
Beijing 8.0 time
0126-15-19T15:00:59.1084+08:00
- all_timezones(options)[source]¶
Dump analysis files for all defined timezones.
-t or –timezones with -P path, -S, and -E (Gregorian Dates)
- mktime(options) list[source]¶
Test that the _mktime method produces the correct local timestamp.
- -m or –mktime with -S, and -E (Gregorian Dates) -A latitude
-O longitude -Z zone
Total derived range -1842 through 1161 with Gregorian years 2 - 3006.
- posix(options)[source]¶
Test that the resultant values from the badi_date_from_timestamp() and timestamp_from_badi_date() methods work correctly with each other.
- -p or –posix with -S and -E (Gregorian Dates) -A latitude
-O longitude -Z zone
- contrib.misc.posix_time._epoch_for_timezone() tuple[source]¶
https://timezonedb.com/ https://www.timeanddate.com/time/map/ https://latitudelongitude.org/
- contrib.misc.posix_time._group_sequences(lst: list) list[source]¶
This function combines all years into a tuple. If there is a spread of years they the first and last year is placed in a tuple which is then placed in the outer tupple.
Thanks to ChatGPT for deriving this algorithm.
- contrib.misc.posix_time.fmt_float(value, left=4, right=4)[source]¶
Format one float so that it is visually centered on the decimal point.
- Parameters:
value (float | int | str) – The number to format.
left (int) – Width to reserve on the left of the decimal (including any minus sign).
right (int) – Number of digits to show after the decimal.