DateTime objects in many programming languages describe an instant in time, expressed as a date and time of day.

learn more… | top users | synonyms

3
votes
0answers
36 views

Scraping efficiently with mechanize and bs4

I have written some code that scrapes data on asteroids, but the problem is that is super slow! I understand that it has a lot to scrape, but as of now it has been running for 5 days and is bot even a ...
11
votes
1answer
44 views

New Moon (not Twilight) Calculator

Photography is one of my hobbies, and, living in Canada, I have the possibility of seeing, and photographing, the Aurora Borealis (Northern Lights). Now, these happen when there's ionization in the ...
4
votes
3answers
29 views

Loop through all virtualhost log files and run goaccess on each file

So I have multiple websites running under apache2 virtualhost - and I wanted to use GoAccess to process the access.log for each site. The directory structure is ...
2
votes
1answer
14 views

Custom moment formats based on string length

Just wanted to gage how solid this code is. With moment cracking down on lazy formatting I thought this was a good way to parse the string for what format to use. ...
9
votes
2answers
1k views

It's almost Friday, right?

This is my final post for my CS1 saga. Mostly all I had to do was just "class-ify" my past project in this post. Here are the requirements: Make all data members private and use constructors, ...
4
votes
3answers
93 views

On What Day Is That Date

I got bored on my long weekend so I decided to have my coding exercise. And I successfully made a program that let you input the day and the month then it gives you the day of given date. But sadly ...
7
votes
2answers
249 views

Set theory clock code

I wrote some JS to power an HTML/CSS "set theory" clock, and I'd like to share what I have so far and ask if anyone can suggest improvements. Specifically, I'm wondering: Should I bother checking ...
3
votes
1answer
33 views

Changing cuts to sed for parsing dates from apache log (common log file)

Would switching my cuts below to SED improve performance? I am trying to get a per date count of requests for the last two weeks from a server log. The script runs, but slowly (comes in around 14 ...
5
votes
4answers
302 views

Finding overlapping time intervals

You have two lists with meetings scheduling (start time, end time). Meetings in single list don't intersect. Find all intersecting meetings across the two lists. Is my complexity \$O(N M)\$? If I ...
3
votes
5answers
208 views

Evaluating Valid Date

I want to write a function which returns true if a selected date is smaller than the current date, else return false. This function is working as expected but I want to know the best possible way to ...
3
votes
2answers
58 views

Reservation validation

I got a Reservation model that has reservation_start and reservation_end. Then I have the ...
4
votes
3answers
239 views

Rounding and formatting hours, minutes, seconds as HH:MM AM/PM

I have a program which is supposed to convert standard time to traditional time. (e.g: 15:24:31 = 3:25PM [rounded seconds]) I would like for someone to error check my code for me as well as give me ...
6
votes
2answers
345 views

Leap year calculator

I'm creating a program to determine whether or not a given year is a leap year. I just wanted to get anyone's feedback on it. I am aware of the calendar module in Python. I just wanted to try it from ...
7
votes
1answer
70 views

Access function to return “number of working days until date” for form

I need a function I can put on a form which does: Calculates number of working days until a given date Excludes weekends Excludes any dates in a "holiday" table This is replacing something which ...
6
votes
2answers
56 views

Generating fiscal calendar dates

I need to generate a T-SQL script for loading data into this table: ...
1
vote
1answer
23 views

Assorted Date Parser

I've written a date parser that parses different types of dates using Parsec. Credit for the original problem goes to here. The following formats are as such: ...
4
votes
2answers
91 views

Implement a Clock in JavaScript

How idiomatic is my code? ...
1
vote
0answers
56 views

Handling hours, minutes, seconds

Basically I wanted to make a generic class for parsing time codes and dealing with small units of time. I have tried to keep it very simple (small API) and 0 dependency (apart from RSpec). Some ...
2
votes
2answers
47 views

Function to validate date format

I have this JavaScript function which checks if the format has 'yyyy' and replaces 'yy' with 'y': ...
3
votes
3answers
185 views

TimeZone computing method

I feel like there is a code smell in this. Can someone help me to refactor/optimize it? ...
3
votes
1answer
69 views

Generating all valid dates

I've come up with the following code to generate a list of all dates between two given dates: ...
2
votes
2answers
33 views

Cluster date time values

I came up with this TSQL for SQL Server 2008: ...
1
vote
1answer
43 views

Counting business days in a month, ignoring holidays

In the past, I have worked mostly in MySQL and SQL Server. Almost everything at my current job is Oracle, though. I could have written this instantly for MySQL but I could barely google what I ...
3
votes
3answers
368 views

DateTime-like class implementation in modern C++

In modern C++, there is no class like datetime in the standard which can be used in the program. However, with additional of modules like ...
1
vote
3answers
30 views

Determine numeric month based on actual moth

The following script uses a switch statement to determine the numeric month based on the actual month. Is there a more succinct way (read: elegant, or less time to write) to accomplish the same ...
3
votes
1answer
43 views

Compute adjacent days from date string

I'm trying to do some datetime processing. The input is a string of the form 20141005 ('%Y%m%d') and I want to return a data ...
3
votes
1answer
64 views

Checking for a date and compare 2 different files

From snippets around the web, I was able to put together this .bat file to check for a date and compare 2 different files. This works below but I want to clean it up so it can be much lighter and ...
4
votes
1answer
69 views

(Swedish) Calendar of the year 2015 using Firebase

I've made a calendar for the year of 2015 using Firebase for real-time updates when something changes in it. I'm quite happy with it but I'm interested in getting some feedback on my Javascripting ...
4
votes
1answer
49 views

Orthodox Easter calculator

I have code for calculating the date for orthodox Easter and it makes me cry when I look at the if-else part. Please give your ...
13
votes
2answers
148 views

It's Friday! - Zeller's Congruence Revisited

A couple of date-related questions have come up recently, and on both occasions I have been taken back to my 'early' days where one of my first forays in to programming involved implementing Zeller's ...
5
votes
1answer
166 views

Logging with date in Java

I write my log messages in JTextArea. Each message should have a time added. I created a following method: ...
14
votes
3answers
3k views

Is it Friday yet?

This is the first program that I have written in my C++ saga that I actually think is useful. The description for this assignment is kinda long and mundane though: Write a program that inputs a ...
5
votes
3answers
87 views

Summing some datum for requests in each domain that fall in a date range

I have a LINQ query which works fine. I am however very interested to understand if this can be written in a more optimum way... ...
1
vote
1answer
86 views

Least suprising extension methods for DateTime to NATO date-time group

I have the following code to get a NATO date-time group for a DateTime. I usually need Zulu-Time or from a specific time zone. Is it clear what those methods are providing? If want to parse a NATO dtg ...
7
votes
1answer
100 views

Filter out date records which don't fall within or span a date range

I have records which have specific time spans. The need is to select records which adhere to the following three rules (read them as or conditions) concerning a ...
4
votes
1answer
91 views

Fast regex to extract strings before and after a time

I want to get text1 and text2 by splitting time format Text1 10:24:02 Text2 Of the ...
7
votes
2answers
832 views

Find the number of working days between two dates inclusively

The objective is to find the number of working days (days spanning from Monday to Friday) between two given dates inclusively. ...
13
votes
1answer
118 views
+50

Chrono-like clock with different epoch (from 1.1. 2000)

The following will by my simple helper, that should behave just like std::chrono::system_clock but with the epoch being 1.1. 2000, that I can easily cast durations ...
10
votes
5answers
766 views

Function for checking leap years

As part of one of my AP Computer Science labs, I was required to write a function to determine whether a year was a leap year or not. Included as comments are a few reasons why I did things, as well ...
6
votes
2answers
66 views

Leap year functionality in Ruby and JavaScript

I did a line-by-line translation and am wondering if the JavaScript code looks idiomatic. Original Ruby code: ...
2
votes
2answers
69 views

Determining the next payment renewal date

I am not very good a JavaScript, surely not date manipulation, but I hacked together the script below with the purpose to determine the next payment renewal date based on a start date and payment ...
5
votes
1answer
54 views

Using a TSV text file and map for a Q&A program

The program outputs a menu asking for a new question or to ask a question. If you ask a question, it will search a .tsv text file for the question and return the answer. It will then check a map that ...
3
votes
2answers
129 views

Designing a Time class [closed]

Problem Statement: 1. Design a class TIME which stores hour, minute and second. The class should have the methods to support the following: User may give the time value in 24-hour format. User may ...
1
vote
1answer
29 views

Observing PEP maximum line size, particularly when formatting localized timestamps

I have this function that I use to publish a message but I need to do this long conversion for time and date. Maybe there's a better way to convert it to make smaller. Otherwise I'm stuck with this ...
7
votes
3answers
71 views

Parsing dates from an OCR application

I wrote this code to parse dates from the output of the OCR, which means that the obtained date can be literally anything, so I put some restrictions in place: Date is the the format of: ...
7
votes
3answers
79 views

Calendar Print Method

I'm currently learning Ruby and need help in editing code to be more idiomatic. I have the method below I could use some pointers on how to make more "Ruby" :-) ...
1
vote
2answers
109 views

Weekly fee calculation

I have the following query. Its execution took 15 min and it's too much slow. Is there a way to optimize it? ...
6
votes
1answer
97 views

Dict of names and birth dates which prints with age at birthday of current year

As a beginner (Learn Python the Hard Way), I've set myself this exercise with classes and it works but looks very inelegant to me. I'm trying to write classes which could be re-used in other code. ...
1
vote
1answer
34 views

Using Regexp to select the date from a string [closed]

I have a string with date details with time, but I would like to show the day information alone. For that, I use the regexp to select the date. Can anyone tell me the regexp, and if what is used is ...
3
votes
1answer
53 views

Python Long UTC DateTime String

now = datetime.datetime.utcnow() now.strftime('%d %b %Y %I:%M:%S.%f')[:-3] + now.strftime(' %p') Is there a cleaner solution for this? I don't want the extra ...