# Is possible to create own time format for day with 26 hours?

**URL:** <https://discourse.julialang.org/t/is-possible-to-create-own-time-format-for-day-with-26-hours/5917>\
**Category:** General Usage\
**Created:** [September 16, 2017, 8:56am UTC](https://discourse.julialang.org/t/is-possible-to-create-own-time-format-for-day-with-26-hours/5917 "2017-09-16T08:56:33Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![programista](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/programista/32/5372_2.png) [@programista](https://discourse.julialang.org/u/programista)\
**Post date:** [September 16, 2017, 8:56am UTC](https://discourse.julialang.org/t/is-possible-to-create-own-time-format-for-day-with-26-hours/5917/1 "2017-09-16T08:56:33Z")

</div>

Is possible to create own time format for day with 26 hours ?

Typical time :  
julia\> x=Dates.DateTime(“20140529 230000”, “yyyymmdd HHMMSS”)  
2014-05-29T23:00:00

In my system day starting at 02:00:00 and end of day is at 25:59:59.:  
How it us.write in Julia Time system ?  
My example:  
julia\> x=DateTime(“20140529 255959”, “yyyymmdd HHMMSS”)  
ERROR: ArgumentError: Hour: 25 out of range (0:23)  
in DateTime(::Int64, ::Int64, ::Int64, ::Int64, ::Int64, ::Int64, ::Int64) at .\dates\types.jl:149  
in DateTime(::Base.Dates.Year, ::Base.Dates.Month, ::Base.Dates.Day, ::Base.Dates.Hour, ::Base.Dates.Minute, ::Base.Dat  
es.Second) at .\dates\types.jl:172  
in DateTime(::String, ::String) at .\dates\io.jl:258

Paweł

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [September 16, 2017, 9:04am UTC](https://discourse.julialang.org/t/is-possible-to-create-own-time-format-for-day-with-26-hours/5917/2 "2017-09-16T09:04:57Z")

</div>

> [@programista](#):
>
> Is possible to create own time format for day with 26 hours ?

Yes.

> [@programista](#):
>
> How it us.write in Julia Time system ?

Your best bet would probably be defining a new type, with the relevant constructors (parsers) and operations. You can probably reuse a lot of code from the implementation in `Base` (which is pretty lightweight anyway).

Alternatively, writing a very, very thin wrapper around `DateTime` that just parses and displays with an offset may be an easy solution, provided that your day has 24 hours (contrary to what you say above), just with an offset.

---

<div class="post-metadata">

**Author:** ![programista](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/programista/32/5372_2.png) [@programista](https://discourse.julialang.org/u/programista)\
**Post date:** [September 16, 2017, 9:09am UTC](https://discourse.julialang.org/t/is-possible-to-create-own-time-format-for-day-with-26-hours/5917/3 "2017-09-16T09:09:31Z")

</div>

Julia Version 0.5.0  
Yes , day have a 24 h but start at :02:00:00  
Offset is possible but my solution must be very speed…  
Paul

---

<div class="post-metadata">

**Author:** ![cstjean](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cstjean/32/1444_2.png) [@cstjean](https://discourse.julialang.org/u/cstjean)\
**Post date:** [September 16, 2017, 1:02pm UTC](https://discourse.julialang.org/t/is-possible-to-create-own-time-format-for-day-with-26-hours/5917/4 "2017-09-16T13:02:11Z")

</div>

If you use an `immutable` for your struct and make sure that all the operations you defined are type-stable (see `Base.Test.@inferred`), the offset solution should be nearly as fast as defining a type from scratch.

---

<div class="post-metadata">

**Author:** ![John\_Hearns](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/john_hearns/32/1685_2.png) [@John\_Hearns](https://discourse.julialang.org/u/John_Hearns)\
**Post date:** [September 17, 2017, 6:53am UTC](https://discourse.julialang.org/t/is-possible-to-create-own-time-format-for-day-with-26-hours/5917/5 "2017-09-17T06:53:30Z")

</div>

Paul, forgive me if I am not understanding your correctly.  
It seems that you have a day which is 24 hours long. You are located in a timezone which is two hours ahead of UTC.  
Why not just use the timezone?  
[https://docs.julialang.org/en/stable/stdlib/dates/#Base.Dates.now-Tuple{}](https://docs.julialang.org/en/stable/stdlib/dates/#Base.Dates.now-Tuple%7B%7D)

“Returns a DateTime corresponding to the user’s system time including the system timezone locale.”  
How do you use another timezone here?  
(For Paul’s purposes translation between the system timezone and UTC is handled)

Actually, thinking about this, for the astronomy community it must be useful to have date and time formats where days are not 24 hours long. How do planetary scientists count dates? I would be interested in the response here from real live planetary scientists!

---

<div class="post-metadata">

**Author:** ![John\_Hearns](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/john_hearns/32/1685_2.png) [@John\_Hearns](https://discourse.julialang.org/u/John_Hearns)\
**Post date:** [September 17, 2017, 7:00am UTC](https://discourse.julialang.org/t/is-possible-to-create-own-time-format-for-day-with-26-hours/5917/6 "2017-09-17T07:00:04Z")

</div>

ps. I have misunderstood this. If Pawel (sorry) is using timezones then the day would be from 02:00 until 02:00 the next day. Would you explain please the reason for having a day extent till 26:00 hours?

pps. I am interested in this because I got quite deep into the Perl DateTime manipulations at one stage. I have never been the same since then.  
Grace Hopper famously had a clock in her office which ran backwards. Do we have a GraceHopper time type?

---

<div class="post-metadata">

**Author:** ![programista](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/programista/32/5372_2.png) [@programista](https://discourse.julialang.org/u/programista)\
**Post date:** [September 17, 2017, 2:49pm UTC](https://discourse.julialang.org/t/is-possible-to-create-own-time-format-for-day-with-26-hours/5917/7 "2017-09-17T14:49:57Z")

</div>

Hi John,  
My day have only 24 hours but is starting at 02:00 and is ending at  
25:59. On media market f.e. movie watched on the TV at 0:30 in sunday is  
reported at 24:30 at saturday before sleep ) ! Its all 🙂  
Paul

W dniu 2017-09-17 o 09:05, John Hearns pisze:

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [September 17, 2017, 4:51pm UTC](https://discourse.julialang.org/t/is-possible-to-create-own-time-format-for-day-with-26-hours/5917/8 "2017-09-17T16:51:01Z")

</div>

> [@programista](#):
>
> movie watched on the TV at 0:30 in sunday is reported at 24:30 at saturday before sleep )

I don’t know your context, but preprocessing your data (eg just subtract 120min) could be the easiest solution.

---

<div class="post-metadata">

**Author:** ![programista](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/programista/32/5372_2.png) [@programista](https://discourse.julialang.org/u/programista)\
**Post date:** [September 18, 2017, 5:50pm UTC](https://discourse.julialang.org/t/is-possible-to-create-own-time-format-for-day-with-26-hours/5917/9 "2017-09-18T17:50:38Z")

</div>

Thanks Tamas, it is True:)  
Paul  
W dniu 2017-09-17 o 18:56, Tamas Papp pisze:
